A Flask template for cookiecutter. (Supports Python ≥ 3.8)
See this repo for an example project generated from the most recent version of the template.
$ git clone https://github.com/cookiecutter-flask/cookiecutter-flask.git
$ cd cookiecutter-flask
# Basic usage (You will be prompted to provide basic information about your application)
$ ./cookiecutter-docker.sh
full_name [Steven Loria]:
...
# The repository for your flask app will be created in a directory with the name
# chosen in "package import name" question (default ./my_flask_app/)
# Additional arguments are available
$ ./cookiecutter-docker.sh --help
Usage: ./cookiecutter-docker.sh [OPTIONS]
Options:
-b, --build Build Docker image before running cookiecutter
-h, --help Show this message and exit
If using standard instructions, Python ≥ 3.8 is required. A virtual environment is recommended (like virtualenv
).
pip3 install cookiecutter
cookiecutter https://github.com/cookiecutter-flask/cookiecutter-flask.git
You will be asked about your basic info (name, project name, app name, etc.). This info will be used in your new project.
After you have generated the project code, a few more steps must be taken before your new app will run. The README of the generated project shows you how to configure and run the application. (You can see the template README here).
- Bootstrap 5 and Font Awesome 6 with starter templates
- Flask-SQLAlchemy with basic User model
- Easy database migrations with Flask-Migrate
- Configuration in environment variables, as per The Twelve-Factor App
- Flask-WTForms with login and registration forms
- Flask-Login for authentication
- Flask-Bcrypt for password hashing
- Procfile for deploying to a PaaS (e.g. Heroku)
- pytest and Factory-Boy for testing (example tests included)
- Flask's Click CLI configured with simple commands
- CSS and JS minification using webpack
- npm support for frontend package management
- Caching using Flask-Cache
- Useful debug toolbar
- Utilizes best practices: Blueprints and Application Factory patterns
- Structuring Flask Apps
- Flask-Foundation by @JackStouffer
- flask-bones by @cburmeister
- flask-basic-registration by @mjhea0
- Flask Official Documentation
MIT licensed.
- Update all node dependencies to latest versions
- Switch to using Github Actions for template CI
- Remove support for Node 10 as a Cookiecutter option
- Refactored Docker image to use multistage builds more efficiently
- Projects generated with the template use Github actions for CI
- Upgrade Webpack to 5.x
- Dropped Python 3.6, 3.7, and 3.8 support
- Added Python 3.9, 3.10, 3.11, and 3.12 support
- Added Node 18 and 20 LTS
- Removed Node 12, 14, and 16 LTS
- Use CalVer (
YY.MINOR.MICRO
). - Upgrade to Bootstrap 4. Thanks @adawalli and @Hiyorim.
- Use environment variables for configuration.
- Add support for Pipenv.
- Upgrade Python and Node dependencies.
- Use webpack for building front-end assets. Front-end dependencies are installed with NPM. Remove Flask-Assets and bower.json. Thanks @wroberts.
- Update Python dependencies.
- Correctly pass first parameter to
Flask
according to the 0.11 docs. Thanks @aliavni. - Remove setuptools and wheel as dependencies to fix deployment on Heroku. Thanks @Cabalist.
- Make User.password a Binary field for compatibility with new versions of bcrypt. Thanks again @Cabalist.
- Use the FLASK_DEBUG system environment variable, instead of MYFLASKAPP_ENV, to control different configs for development and production environments
- Fix
invoke test
command.
- Update to Flask 0.11.
- Use Click instead of Flask-Script for CLI commands.
- Update stale requirements.
- Add CSRF protection.
- Run
lint
command on Travis builds. - Test against Python 3.5.
- Update stale requirements.
- Add
lint
,clean
, andurls
management commands. - Add isort.
Thanks @andreoliw for these contributions.
- Update extension import style to flask_* as per mitsuhiko/flask#1135.
- Update stale requirements (Werkzeug, Flask-WTF, WTForms, Flask-Bcrypt, Flask-DebugToolbar, Flask-Migrate, Bootstrap, jQuery). Thanks @bsmithgall for notifying me of the critical patch to Flask-Migrate.
- Test the cookiecutter on Travis. Thanks @joshfriend.
- Update stale requirements (Flask-WTF, Flask-Migrate, Flask-DebugToolbar)
- Fix .travis.yml.
- Update stale requirements (Flask-WTF, WTForms, Flask-SQLAlchemy, jquery, Bootstrap)
- Add
BaseFactory
class. - Add compat.py module.
- Tests pass on Python 3.
- Update factories to factory-boy >= 2.4.0 syntax.
- Update stale requirements.
- Update stale requirements (Werkzeug 0.9.6, WTForms 2.0)
- Fix unmatched div tag in home.html (thanks @level09)
- Add ReferenceCol for less verbose foreign key columns.
- Add SurrogatePK mixin for adding integer primary key to a model.
- Add base Model class that has CRUD convenience methods.
- Fix setting BCrypt encryption complexity. Tests are much faster.
- Add Role model to show ReferenceCol usage.
- Switch to pytest.
- Upgrade all out-of-date requirements.
- More test examples.
- Remove "year" from cookiecutter.json (just change LICENSE if necessary).
- Fix static assets.
- Update default year in cookiecutter.json. Thanks @Omeryl
- Correct testing of redirects in webtests. Thanks @Widdershin
- Fix POST action in nav form. Thanks @Widdershin.
- Update Bootstrap (3.1.1) and jQuery (2.1.0)
- Optional support for bower.
- Minified assets aren't used in dev environment.
- More modular organization: each blueprint contains its own view, models, and forms in a directory. There is still a single directory for templates and static assets.
- Use Flask-Bcrypt for password hashing.
- Flask-Login for authentication.
- Simple test setup. Just create a subclass of
DbTestCase
. - Flask-Testing support.
- Use Factory-Boy for test factories.
- Use WebTest for functional testing.
- Add Flask-Debugtoolbar.
- Migrations using Flask-Migrate.
- Caching using Flask-Cache.
- Add error page templates (404, 401, 500)
- Add Font Awesome 4.0.3 for icons.
- Add manage.py script
- Add Flask-Assets for CSS and JS bundling+minification
- Use different configs for development and production environments, controlled by the MYFLASKAPP_ENV system environment variable
- Use Blueprints and application factory pattern. The
simple
branch does not use these.
- First iteration
- Bootstrap 3 final
- Working User model and registration