← Flask learning pathFlask · Module 6 of 10
Blueprints and app structure
Organise larger apps with blueprints and the app factory.
📖 Key ideas
- Blueprints group routes: bp = Blueprint("auth", __name__).
- Register: app.register_blueprint(bp, url_prefix="/auth").
- App factory: def create_app(): builds and configures the app.
- Config classes for development, testing and production.
- 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