Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

WNSTXN/flask-boilerplate

Repository files navigation

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.