Skip to content

Instantly share code, notes, and snippets.

@yfe404
Created April 3, 2018 13:01
Show Gist options
  • Save yfe404/c7b8c8a49a6221a38b67b875519feeca to your computer and use it in GitHub Desktop.
Save yfe404/c7b8c8a49a6221a38b67b875519feeca to your computer and use it in GitHub Desktop.
Basic flask app factory pattern
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