Skip to content

Flask application template for kickstarting development of small to medium sized applications

License

Notifications You must be signed in to change notification settings

stewartadam/flask-kickstart

Repository files navigation

flask-kickstart

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.

Features

  • 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

Configuration is loaded in the following order:

  1. Individual environment variables (per code in DefaultConfig from myapp/config.py)
  2. Flask config file instance/myapp.cfg if it exists (copy from myapp.cfg.sample to try it out)
  3. Flask config file pointed to by the CONFIG_FILE environment variable

Deployment

Local (debugging only)

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.

Docker

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.

Azure App Service

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.

Further reading

About

Flask application template for kickstarting development of small to medium sized applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published