Flask application template for kickstarting development of small to medium sized applications, focused on providing the framework for a simple DB + REST API.
For large applications with more features, I recommend cburmeister/flask-bones.
- Boilerplate Flask app structure that separates out models, views and configuration
- Simple REST API for CRUD operations against the configured object models (flask-restless)
- Provisions a simple SQLite database (flask-sqlalchemy)
- Captures and prints tracebacks on syntax error (flask-failsafe)
- Rate limiting against routes and API endpoints (flask-limiter)
Note: For more advanced REST APIs (i.e. those not tied to DB models), I recommend switching to flask-restful instead. It does less out of the box but is far more flexible.
Configuration is loaded in the following order:
- Individual environment variables (per code in
DefaultConfig
frommyapp/config.py
) - Flask config file
instance/myapp.cfg
if it exists (copy frommyapp.cfg.sample
to try it out) - Flask config file pointed to by the
CONFIG_FILE
environment variable
pipenv is the Python.org recommended way to manage project dependencies and virtual environments.
Once installed, simply execute pipenv install -r requirements.txt
to automatically create a virtualenv and install all project dependencies.
The server can be executed with pipenv run python server.py
. It will automatically reload when changes are detected to the Python source files.
A Dockerfile
is provided in the project. To build and run the image:
docker build -t flask-kickstart .
docker run -it --rm -p 8000:80 --name flask-kickstart-runtime flask-kickstart
See GrahamDumpleton/mod_wsgi-docker for additional usage and details.
The app is ready to deploy to App Service, just connect the Web App to your Git repo with these files in it.
For more details, see Git Publishing and Create a Python web app in Azure.