An opinionated boilerplate for web development with Flask, helping you stay productive while following best practices.
- Python3.6 - A programming language that lets you work more quickly.
- Flask - A microframework for Python based on Werkzeug, Jinja 2 and good intentions.
- Virtualenv - A tool to create isolated virtual environments.
- Flask-SQLAlchemy - For database management.
- Flask-Migrate - For migrations.
- Flask-Login - For authentication.
- Pytest - For testing.
Requirements
- Mac OS X, Windows or Linux
- Python 3.6
- Virtualenv
- Start by creating a new project and initiate a git repository:
mkdir myproject && cd myproject
git init
- Pull the content of this repository into your project's repo:
git pull https://github.com/tonymontaro/flask-starter-kit.git
- Create and activate a virtual environment in python3:
virtualenv -p python3 venv && source venv/bin/activate
- At this point, you can finish the installation with the command:
make install
or simply proceed with the remaining steps below.
- Create a .env file and copy over content from the file env_sample on the root directory. In the .env file, you can specify things like the Database URL (the app uses sqlite by default but this behavior can be over-ridden here with something like postgres).
cp env_sample .env
- Install the dependencies:
pip install -r requirements.txt
- Migrations; run the following commands in order:
flask db init
flask db migrate
flask db upgrade
When a change is made to the models
, the last two commands (migrate and upgrade) will need to be run.
- Finally, run the application
flask run
- Run the tests with:
pytest
- Show test coverage on the console:
pytest --cov=app
- Generate html files containing test coverage:
pytest --cov=app --cov-report=html
Api documentation: Generated with Postman
MIT