WNSTXN / flask-boilerplate

The most Pythonic Flask boilerplate.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flask-boilerplate

linting: pylint

flask-boilerplate features improved type hints and developer ergonomics out of the box. More about Flask here.

Requirements

Installation

The installation script only supports Arch or Debian-based systems. If you are on any other platform, you will have to install Docker manually here.

sh requirements.sh

Usage

sh launch.sh -n $APP_NAME

Architecture

Routes

Routes defined in the routes directory are automatically initialised. Each route should be defined in a separate file.

# app/routes/submit_score.py

from app import App
from app.libs import SQLExtension
from app.models import User

@App.get('/submit_score')
def submit_score() -> str:
    
    username = request.form["username"]
    score = request.form["score"]
    
    player = User(username, score)
    SQLExtension.db.session.add(player)
    SQLExtension.db.session.commit()

Models

All models should inherit from the BaseModel dataclass. This ensures that all models are always serialisable and will never need to reimplement id.

About

The most Pythonic Flask boilerplate.


Languages

Language:Python 76.4%Language:Shell 17.6%Language:HTML 3.3%Language:Dockerfile 2.7%