Skip to content

Introduction to Blueprints

Blueprints let you organize routes into modules.

Instead of one giant app.py, you can split features like:

  • auth
  • blog
  • admin
  • api

Each module can own:

  • routes
  • templates
  • static files
  • Flask() app is the “main application”
  • Blueprint() is a reusable, modular set of routes
diagram Diagram mermaid
  • Keeps routes manageable
  • Encourages separation of concerns
  • Makes collaboration easier
  • Works well with the app factory pattern

auth/routes.py:

python
from flask import Blueprint
 
auth_bp = Blueprint("auth", __name__)
 
 
auth_bp.route("/login")(lambda: "login")

You still must register the blueprint with the app (next page).

pch.coffeeTagline

pch.coffeeCta

pch.feedbackHeading

pch.feedbackSubheading