Skip to content

Latest commit

 

History

History
59 lines (39 loc) · 1.6 KB

README.md

File metadata and controls

59 lines (39 loc) · 1.6 KB

Fastapi Boilerplate project

This is a boilerplate project for fastapi. It is based on the fastapi official tutorial. It aims to be a simple MVC project with a database connection. The example is a simple todo list.

It uses Jinja2 as a template engine and Prisma as an ORM.

For the frontend, it uses Bootstrap and HTMX.

Requirements

Quickstart

Running the project

cp docker-compose.override.yml.dist docker-compose.override.yml 
docker compose up

Development

# Install dependencies
poetry install

# Run the project
poetry run uvicorn app.main:app --reload

Project quality

# Run tests
poetry run pytest

# Run linters
poetry run ruff . --fix
poetry run black .

Application structure

Declare a new route

To declare a new route, you need to create a new file in the app/routes directory. The file must contain a router variable that is an instance of fastapi.APIRouter. It will be automaticaly binded to the fastapi application.

# app/routes/my_route.py
from fastapi import APIRouter

router = APIRouter(prefix="/my_route")

@router.get("/helloworld")
async def my_route():
    return {"message": "Hello World"}