a webring for puppies and kitties
Go to file
Elizabeth Hunt 6f223d2462
continuous-integration/drone/push Build is passing Details
add server url for openapi spec, proxy headers spec
2024-08-07 21:23:58 -07:00
data add ci/cd 2024-08-07 21:10:01 -07:00
kennel add server url for openapi spec, proxy headers spec 2024-08-07 21:23:58 -07:00
static feat: add static and template rendering 2024-08-07 20:11:52 -07:00
templates feat: add static and template rendering 2024-08-07 20:11:52 -07:00
tests add ci/cd 2024-08-07 21:10:01 -07:00
.drone.yml add ci/cd 2024-08-07 21:10:01 -07:00
.gitignore initial commit that i did NOT steal from anywhere 2024-08-07 19:46:46 -07:00
Dockerfile add server url for openapi spec, proxy headers spec 2024-08-07 21:23:58 -07:00
README.md initial commit that i did NOT steal from anywhere 2024-08-07 19:46:46 -07:00
docker-compose.yml add ci/cd 2024-08-07 21:10:01 -07:00
poetry.lock feat: add static and template rendering 2024-08-07 20:11:52 -07:00
pyproject.toml add ci/cd 2024-08-07 21:10:01 -07:00

README.md

fastapi-poetry-starter

Description

A project starter for personal usage containing the following:

Prerequisites

1. Install Python 3 and Poetry

MacOS (using brew)

brew install python3 poetry

Ubuntu/Debian

sudo apt install python3 python3-venv pipx
pipx ensurepath
pipx install poetry

2. Create a virtual environment with all necessary dependencies

From the root of the project execute:

poetry install

3. Activate your virtual environment

From the root of the project execute:

poetry shell

Run application

Runs the FastAPI web application on port 8000 using uvicorn:

uvicorn fastapi_poetry_starter.main:app --reload

Testing

pytest

With coverage

pytest --cov=app

With coverage and HTML output

pytest --cov-report html --cov=app

Linting

ruff check fastapi_poetry_starter/* tests/*

Formatting

ruff format fastapi_poetry_starter/* tests/*

Containerisation

The following podman commands are direct replacements of the Docker CLI. You can see that their syntax is identical:

1. Build image and tag it as fastapi-poetry-starter

podman image build -t fastapi-poetry-starter .

2. Run a container of the previously tagged image (fastapi-poetry-starter)

Run our FastAPI application and map our local port 8000 to 80 on the running container:

podman container run -d --name fastapi-poetry-starter -p 8000:80 --network bridge fastapi-poetry-starter

3. Check running containers

podman ps
CONTAINER ID  IMAGE                            COMMAND               CREATED         STATUS             PORTS                 NAMES
78586e5b4683  localhost/fastapi-poetry-starter:latest  uvicorn main:app ...  13 minutes ago  Up 5 minutes ago  0.0.0.0:8000->80/tcp  nifty_roentgen

4. Hit sample endpoint

Our FastAPI server now runs on port 8000 on our local machine. We can test it with:

curl -i http://localhost:8000/healthcheck

Output:

HTTP/1.1 200 OK
server: uvicorn
content-length: 0