This project includes both a requirements.txt
(for pip
) and Pipfile
(for pipenv
).
It is preferable to use pipenv
. To set up and load dependencies:
# Install pipenv if needed
python3 -m pip install pipenv
# Create a pipenv shell in this directory after cloning
pipenv shell
# Install dependencies
pipenv install -r requirements.txt
As typical with FastAPI development, run the local server as you code:
# cd into the app/ directory
cd app
# run the local uvicorn server (install locally first)
Your dev site is now running locally at http://localhost:8000/ and will refresh automatically with changes.
This template contains a variety of methods and endpoints:
Adds two integers taken as URL path parameters
{
"sum": 10
}
Takes an integer path parameter 1234567890
as well as two query string parameters foo
and bar
.
{
"item_id": 1234567890,
"q": "foo",
"s": "bar"
}
For more on catching POST payloads in JSON, or form parameters, consult the FastAPI documentation.
Build locally with the docker build
command:
docker build -t some_org/some_image:some_tag .
Run the image locally and map the container port (80) to some host port (8080):
docker run -d -p 8080:80 --rm some_org/some_image:some_tag
Look in .build.yml
for a sample template that completes the following steps:
- Builds the container image.
- Pushes the new image to the container registry of your choice (i.e. Docker Hub, GHCR, etc.)
- (Optional) Publish a message for deployment in K8S, etc.
To enable this pipeline, place it in .github/workflows/
and git push. Some repository secrets must be set before builds will work.