Created
April 3, 2018 13:01
-
-
Save yfe404/c7b8c8a49a6221a38b67b875519feeca to your computer and use it in GitHub Desktop.
Basic flask app factory pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_app(): | |
""" | |
Create Flask application using the app factory pattern. | |
:return: Flask app | |
""" | |
app = Flask(__name__, instance_relative_config=True) | |
app.config.from_object('config.settings') | |
app.config.from_pyfile('settings.py', silent=True) | |
@app.route('/') | |
def index(): | |
""" | |
Render a Hello World response. | |
:return: Flask response | |
""" | |
return 'Hello World!' | |
return app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment