Flask apps minimal blueprint
Folder structure.
/project
├── /MyApp
│ ├── __init__.py
│ └── routes.py
└── wsgi.py
Run flask run
inside your project folder to start your server.
from MyApp import create_app # <-- MyApp = MyApp Folder
app = create_app()
if __name__ == "__main__":
app.run(host='127.0.0.1', debug=True)
"""Initialize Flask Application."""
from flask import Flask
def create_app():
"""Construct the core application."""
app = Flask(__name__)
with app.app_context():
from . import routes
return app
"""Route declaration."""
from flask import current_app as app
@app.route("/")
def home():
return "Hello World!"