~busykoala/py_web_scratch

FastAPI example app.
8d44bc37 — Matthias Osswald 1 year, 29 days ago
Ignore test db.
4817c1d9 — Matthias Osswald 1 year, 29 days ago
Setup migrations.
1d07dff4 — Matthias Osswald 1 year, 2 months ago
Add and apply linter.

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~busykoala/py_web_scratch
read/write
git@git.sr.ht:~busykoala/py_web_scratch

You can also use your local clone with git send-email.

#Web Scratch with FastAPI

#Install

poetry install [--no-dev]

#Run

poetry run uvicorn app.main:app [--reload]

#Run in Docker

docker build -t fastapi-app
docker run -p 8000:80 fastapi-app:latest
# it will then run on localhost:8000

#DB Migrations

On start up the migrations are automatically applied.

# add a migration
poetry run alembic revision -m "Name of the revision"

# add a migration with autogeneration
poetry run alembic revision --autogenerate -m "Name of the revision"

# more options
poetry run alembic --help

#Test & Lint

poetry run pytest

poetry run black [--check] .
poetry run flake8 .
poetry run isort . [--check]
poetry run bandit -r app

#Documentation

There is a graphql endpoint on /gql. Test using:

{
  hello(name: "Yolo")
}

The other endpoint are self-documenting using swagger (see /docs).