Skip to content

Quickstart

This chapter walks you through a minimal Flask application to get you started, and helps you understand development mode and project entry point.

Minimal Application:

python
from flask import Flask

app = Flask(__name__)

@app.route("/")
def index():
    return "Hello, Flask!"

if __name__ == "__main__":
    app.run(debug=True)

Run in Development Mode:

bash
export FLASK_APP=app.py  # Windows: set FLASK_APP=app.py
export FLASK_ENV=development  # Enable debug and auto-reload (Flask 3+ uses --debug instead)
flask run --debug

Route Method Shortcuts:

  • @app.get("/path") - GET only
  • @app.post("/path") - POST only
  • @app.route("/path", methods=["GET","POST"])

Auto Reload: Development server automatically restarts after saving code changes. Note: Do not enable debug=True in production.

Recommendation: Wrap your application as a factory function for easier testing and multi-instance creation (introduced in the App Structure chapter).

Content is for learning and research only.