Flask Blueprints


Blueprints are a powerful concept in Flask application development that allow for flask applications to be more modular and be able to follow multiple patterns. They make administration of very large Flask applications easier and as such can be used to scale Flask applications. You can reuse Blueprint applications however you cannot run a blueprint on its own as it has to be registered on your main application.

A basic flask blueprints example

A minimal Flask application looks something like this:

from flask import Flask
app = Flask(__name__)

def index():
    return "Hello World!"

A large Flask application can separate one file into multiple files by blueprints.


Make it easier for others to maintain the application.

Folder Structure of Large Application



from flask import Blueprint, render_template

index_blueprint = Blueprint('index', __name__)

def index():
    return "Hello World!"


from flask import Flask
from views.index import index_blueprint

application = Flask(__name__)

Run application

$ export FLASK_APP=app.py
$ flask run