- as a main library
- as a database library
- as a dependency manager
- π¨ OpenAPI docs on
api/docs
andapi/redoc
- π Docker support with
docker-compose
- π Create and clone repo from this template
- π Rename
example.toml
toconfig.toml
and change api settings
- π Install poetry with command
pip install poetry
- π Install dependencies with command
poetry install
- π Run project via
python -m app
You can start the project with docker using this command:
docker-compose -f deploy/docker-compose.yml --project-directory . up --build
But you have to rebuild image every time you modify poetry.lock
or pyproject.toml
with this command:
docker-compose -f deploy/docker-compose.yml --project-directory . build
$ tree "app"
app
βββ __init__.py
βββ __main__.py # Startup script. Starts uvicorn.
βββ application.py # FastAPI application configuration.
βββ settings.py # Main configuration settings for project.
βββ api # Package with all handlers.
βΒ Β βββ __init__.py
βΒ Β βββ router.py # Main router.
βββ db # module contains db models
βΒ Β βββ __init__.py
βββ events
βΒ Β βββ __init__.py
βΒ Β βββ shutdown.py # Shutdown event.
βΒ Β βββ startup.py # Startup event.
βββ middlewares # Package contains middlewares.
βΒ Β βββ __init__.py
βΒ Β βββ main.py # Main middleware.
βββ static # Static content.
βββ docs
βββ redoc.standalone.js
βββ swagger-ui-bundle.js
βββ swagger-ui.css
To install pre-commit simply run inside the shell:
pre-commit install
pre-commit is very useful to check your code before publishing it. It's configured using .pre-commit-config.yaml file.
By default, it runs:
- black (formats your code);
- flake8 (spots possible bugs);
You can read more about pre-commit here: https://pre-commit.com/