Skip to content

odiroot/mofanhu

Repository files navigation

mofanhu

A robust template for Flask applications.

https://www.flickr.com/photos/sophies/5393505900/

[..] Put water into a bottle it becomes the bottle.

Features

  • Python 3.8 as a base.
  • Clean and organised structure for a medium size or large web project.
  • Staying close to the 12 Factor App ideals.
  • Well configured Flask CLI tool for user friendliness.
  • Integrated Konch and DebugToolbar for easier debugging.
  • Project configuration based on environs for automatic validation and type conversion.
  • Development configuration using direnv, overridable by environment variables.
  • Serving dynamically rendered HTML page and example static files with pure Flask. Example template.
  • Example API endpoints in two flavours: Flask-RESTful and flask-smorest.
  • Support for PostgreSQL database and ORM models using SQLAlchemy. Example model.
  • Support for migrations with alembic. Example migration.
  • Support for background tasks with dramatiq. Example task.
  • Configuration for running on Heroku cloud.
  • Separate production, testing and development requirements.
  • Easy testing with tox and py.test. Example tests.
  • Support for fast and efficient testing of database code using transactions and parallel workers.
  • Basic code linting with black, flake8 and isort.
  • Github Actions testing with Python application setup.
  • Easy entry vector for WSGI servers, demonstrated with Gunicorn.
  • Dockerfile to build a minimal¸ production-ready Docker image.
  • Rudimentary definition for Docker Compose to launch the complete project.
  • Practical CRUD UI using Flask-Admin.
  • EditorConfig support.

Running

With Docker

Note: Ensure you have a working system Docker installation.

Install Docker Compose:

$ pip install -U docker-compose

Start the complete stack in a standard way:

$ docker-compose up --build --detach

Check the logs

$ docker-compose logs --follow

Manually

Note: Ensure you have a working Python 3.8 installation.

Create a virtualenv:

$ virtualenv -p `which python3.8` .env

Install dependencies:

$ source .env/bin/activate
$ pip install -Ur requirements.txt

Prepare the environment (direnv has to be preinstalled):

$ cp envrc.example .envrc
$ direnv edit

Run the development web server:

$ flask run

Tests

Install the tooling:

$ pip install -U tox

Run the tests

$ tox

About

A robust template for Flask applications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •