ahoyt41 / fastapi-example

This is an example FastAPI project used to present FastAPI and pydantic for rockypython.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FastAPI Example

This project is an example of a FastAPI application used to present FastAPI and pydantic for Rocky Python. It is a basic score board application.

Setup

The project uses poetry for dependency managment and poethepoet for running tasks.

Install Poetry

# with the official installer
curl -sSL https://install.python-poetry.org | python3

#globally with pip
pip install poetry

# or with pipx
pipx install poetry

Install poethepoet

# systemwide with pip
pip install poethepoet

# or per user with pipx 
pipx install poethepoet

Install Depedencies

poetry install

Install Client Depedencies

The project also includes a client implementation using httpx. To install client dependencies run

poetry install -E client

Setting up the "database"

This project uses a json file as mock database named fastapi_example.db.json If this file is missing, it can be generated by running poetry run python scripts/create_data.py

Running the server

To run the server you can either use the predefined poe task

poe run

Or start it up manually

poetry run uvicorn fastapi_example:app

Running the Demo

The demo script scripts/demo.py shows an example of how to interface with the API as well as some of its data validation capabilites. The script can be run with poe via

poe demo

About

This is an example FastAPI project used to present FastAPI and pydantic for rockypython.org


Languages

Language:Python 100.0%