Flask-Boilerplate cookiecutter template
This is a CookieCutter template for generating a generic Flask project. It provides simple starting points for using some of the popular best-practices:
- Proper setuptools-compatible package layout.
- Several of nearly-standard extensions (Flask-SQLAlchemy, Flask-Login, Flask-Admin, Flask-Script)
- py.test-based tests.
- Usage of the Travis-CI continuous integration service.
Before you can use this template you should install
$ pip install cookiecutter
cookiecutter executable should appear in your Python's
bin/ (in Windows
Scripts/) directory. You might need to add that directory to your
PATH to run the executable. You should also have
git installed in your system.
To initialize a new project, ensure that
cookiecutter is in your path and run:
$ cookiecutter https://github.com/konstantint/cookiecutter-flask-boilerplate.git
After asking some basic questions, the tool will create the following project layout for you::
Typically you would want to add the newly created project to the version control before doing anything else:
$ git init $ git add . $ git commit -m "Initial package structure"
To give a quick test run of the resulting project, proceed as follows:
$ python setup.py develop $ <project>-manage createdb $ <project>-manage assets build $ <project>-manage runserver
Common development tasks
Specifying a local configuration
$ cp sample_settings.py settings.py ... edit settings.py ... $ export CONFIG=/path/to/settings.py ... (can be just "settings.py", if you plan to run everything from the same directory) ...
$ py.test .. or .. $ python setup.py test
Specifying dependencies for your package
setup.pyby listing all the dependent packages.
Using the debug shell Run
<project>-manage shell. The resulting shell provides variables
Publishing the package on Pypi
$ python setup.py register sdist upload
To use the Travis-CI continuous integration service, follow the instructions at the Travis-CI website to register an account and connect your Github repository to Travis. The boilerplate code contains a minimal
.travis.ymlconfiguration file that might help you get started.
- Alternative flask templates:
- Buildout project boilerplate template: https://github.com/konstantint/cookiecutter-python-boilerplate
- Blog post: http://fouryears.eu/2015/04/21/a-flask-project-template/
Copyright & License
- Copyright 2015, Konstantin Tretyakov
- License: MIT