Skip to content

A demo project showing the combined use of connexion, sqlalchemy and asyncio.

Notifications You must be signed in to change notification settings

nicolashimmelmann/async-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-rest-api

This project shows one way of setting up an async REST API with a database based on the following libraries:

The database session is instantiated per request in a custom ASGI middleware and stored in a context variable scoped to the current async task which processes the request.

How to run

The whole setup can be run with Docker:

docker compose build
docker compose up

The API will listen on http://127.0.0.1:8080/api/v1.

Sending simple requests

Write a new user:

curl -X POST -H "Content-Type: application/json" \
  -d '{"username": "Max"}' \
  http://127.0.0.1:8080/api/v1/user

Read all users:

curl -X GET http://127.0.0.1:8080/api/v1/user

Viewing the database

For simplicity, I have added a container with pgadmin to the docker compose file. Using that tool, you can easily view the database contents by opening a web browser at http://127.0.0.1:8081

About

A demo project showing the combined use of connexion, sqlalchemy and asyncio.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published