- 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/