← Flask learning path
Flask · Module 6 of 10

Blueprints and app structure

Organise larger apps with blueprints and the app factory.

📖 Key ideas

  1. Blueprints group routes: bp = Blueprint("auth", __name__).
  2. Register: app.register_blueprint(bp, url_prefix="/auth").
  3. App factory: def create_app(): builds and configures the app.
  4. Config classes for development, testing and production.
  5. Structure: app/__init__.py, routes/, models.py, templates/.
💡 Real-life example: Blueprints are departments in a company: each handles its own work but shares one building.
BlueprintGroup of routes and templates
App factoryFunction that creates the app
url_prefixPrefix for blueprint URLs
Config classSettings per environment