Book Image

Flask Blueprints

By : Joel Perras
Book Image

Flask Blueprints

By: Joel Perras

Overview of this book

Table of Contents (14 chapters)

Starting off


We once again reach for our basic Blueprint-based application structure and create a whole new virtual environment and directory for this new venture:

$ mkdir -p ~/src/hublot && cd ~/src/hublot
$ mkvirtualenv hublot
$ pip install flask flask-sqlalchemy flask-script

The application layout that we'll start off with is very similar to what we used in previous Blueprint-based projects, with the main difference being the manage.py script, which will be the main entry point for our Flask-Script CLI commands. Also note the lack of run.py and a database.py, which we alluded to previously and will explain in more detail shortly:

├── application
│   ├── __init__.py
│   └── repositories
│       ├── __init__.py
│       └── models.py
└── manage.py

In keeping with our previous work, we continue to use the Application Factory pattern to allow the instantiation of our application to happen at runtime instead of at module import time, as we shall do with the Flask-SQLAlchemy extension...