📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Flask Web Framework Flask Blueprints

Flask Blueprints

5 min read Quiz at the end
Split Flask apps into Blueprints: modular route groups with their own templates and static files.

Blueprints — Modular Apps

# app/auth/__init__.py
from flask import Blueprint

auth_bp = Blueprint("auth", __name__, template_folder="templates")

@auth_bp.route("/login", methods=["GET","POST"])
def login():
    pass

@auth_bp.route("/logout")
def logout():
    pass

@auth_bp.route("/register", methods=["GET","POST"])
def register():
    pass

# app/posts/__init__.py
posts_bp = Blueprint("posts", __name__)

@posts_bp.route("/")
def index():
    pass

@posts_bp.route("/")
def show(id):
    pass

# Register in factory
app.register_blueprint(auth_bp,  url_prefix="/auth")
app.register_blueprint(posts_bp, url_prefix="/posts")
Topic Quiz · 3 questions

Test your understanding before moving on

1. What is a Blueprint in Flask?
💡 Blueprints split a Flask app into reusable modules with their own routes.
2. How do you register a Blueprint?
💡 app.register_blueprint() attaches the blueprint to the app.
3. Why use the Application Factory pattern?
💡 create_app() function allows different configs per environment.