Skip to content

kigawas/flask-scaffold

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

flask-scaffold

Codacy Badge Github Actions Docker Build Status License

A scaffold to speed up launching a flask project, set up with minimal dependencies.

You can just remove LICENSE, .git/, and .vscode/ files if you don't need them.

There is no silver bullet, so if other libraries or practice are preferred, you can add or change anything as you like.

Prerequisites

  • Python 3.7+

  • Poetry

  • (Optional) Docker and docker compose

Main features

  • APIFlask
  • Blueprint templates to organize directory structure
  • Colorful logger in terminals, stolen from tornado
  • Gunicorn aiohttp server for production use
  • Integrated with static analysis and lint tools like mypy, black, flake8 and git hook tool pre-commit
  • Default Github Actions and Heroku configuration

Common tasks

Create virtual environment with dependencies

python3 -m venv venv && source venv/bin/activate && poetry install

Specify development config (with debug mode on)

export FLASK_ENV=development

Run development flask server

flask run

Run development gunicorn server with aiohttp worker

gunicorn -b :5000 aioapp:aioapp -k aiohttp.worker.GunicornWebWorker --reload

Run production gunicorn server

./boot.sh

Build docker image

docker build .

Run with docker compose

docker-compose up --build

Format Python code with black

black . --exclude venv

Run git pre-commit hooks

pre-commit run --all-files