Skip to content

A template for a Python FastAPI service with Poetry & Devcontainer

License

Notifications You must be signed in to change notification settings

IbraheemTuffaha/python-fastapi-template

Repository files navigation

pytest Action format Action Python Version GitHub License Quality Gate Status

Python FastAPI Template

A template for a Python FastAPI service:

Build and run locally

Using python3.12 install poetry:

pip install poetry

Then install dependencies

poetry install

Run locally

poetry run uvicorn app.main:app --port 8000 --reload

Run tests

poetry run pytest

Build and run using Docker

docker build -t app .
docker run -p 8000:8000 -it app

Notes

  • If you face an issue with git ssh access while pushing new changes, run ssh-add $HOME/.ssh/<your ssh key> in terminal outside the devcontainer.

  • If you face an issue during devcontainer build, make sure the repo is marked as trusted in VSCode. Check Source Control tab in the sidebar to mark the repo safe, then rebuild the devcontainer.

Sample CRUD API

The /v1 directory contains a sample API router demonstrating basic CRUD operations for users:

  • Endpoints: Create, Read, Update, Delete users
  • Router setup: app/v1/routers/base.py and app/v1/routers/users.py
  • User model: app/v1/models/user.py
  • User management: app/v1/services/user/user_manager.py

Use the samples as a starting point for your own API endpoints. View available endpoints at http://localhost:8000/docs.

About

A template for a Python FastAPI service with Poetry & Devcontainer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published