A Flask bootstrap and application skeleton with twelve-factor principles.
Bootstraps a typical Flask application with authentication, SQL database, forms and caching. Constructed of modular apps separating data modules, HTML-based views, JSON-based API responses and an authentication-protected admin interface.
Includes an example
model for the purpose of demonstration SQL querying and basic CRUD admin actions. Basic templates and static file structure also in place.
- Flask - Python Web framework
- Flask-SQLAlchemy - Flask extension for SQLAlchemy
- Flask-Login - user session management
- Flask-WTF - Flask integration with WTForms
- Flask-Cache - Cache extension for Flask
- Flask-Script - command-line tasks and scripts
- Gunicorn - WSGI HTTP server
- Honcho - a Python clone of Foreman
- Fabric - command-line system admin, deployment, remote management
- IPython - interactive shell
-
Install requirements (use virtualenv)
$ pip install -r requirements.txt
-
Initialise database with Fabric
$ fab setup
-
Run with Fabric
$ fab run
Honcho adds the contents of .env
file as environment variables. The application boostrap configures Flask using these settings, so edit this file as you please - see Flask configuration.
Note: Defaults are defined in the config class for some settings, so you don't need to duplicate these in your .env
if you want to keep it minimal. Currently SERVER_NAME
(which is used to determine the application HOST
and PORT
), SQLALCHEMY_DATABASE_URI
and SECRET_KEY
are the only required settings.
Obviously, SECRET_KEY
should be something considerably stronger than the example.
To run with Flask's development server, use:
$ fab dev
Set DEBUG=True
in your .env
file to auto-reload with code changes. See the fabfile for other commands.
- Flask wiki, Flask-skeleton and Fbone for inspiration
- The Twelve-Factor App
- Declaring and Scaling Process Types with Procfile
- Dana - Django flavoured Twelve-Factor boilerplate
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License