Clone this repository{:target="_blank"} and install the dependencies. This project uses uv{:target="_blank"} for dependency management which should be installed on your system first.
Install the dependencies:
uv syncThen switch to the virtual environment:
# On Linux:
source .venv/bin/activate
# On Windows:
.venv\Scripts\activateRun the server using Uvicorn:
uvicorn main:app --reload!!! note
You can also run the server by just executing the main.py file:
```console
python main.py
```
or using the included `POE` alias:
```console
poe serve
```
Then open your browser at http://localhost:8000{:target="_blank"}.
There is only one endpoint available: /users. It returns a list of all users
for a GET request and creates a new user for a POST request.
This example uses PostgreSQL{:target="_blank"} as the database. If you dont have a local PostgreSQL database running, you can start one with Docker{:target="_blank"} using the following command:
docker run \
--rm \
--name postgres \
-p 5432:5432 \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-d postgresThis will run a PostgreSQL database in a Docker container in the background. When you are finished and want to stop the database, run:
docker stop postgresIf needed, you can connect to the database managment by :
docker exec -it postgres psql -U postgresThis will allow you to edit or delete the database or records.
For testing purposes, you can also use SQLite{:target="_blank"}
instead of PostgreSQL. To do so, open the db.py file and comment out the
PostgreSQL database in the DATABASE_URL environment variable and uncomment the
SQLite database.
# DATABASE_URL = "postgresql+asyncpg://postgres:postgres@localhost/postgres"
DATABASE_URL = "sqlite+aiosqlite:///./test.db"