Sitelet https://github.com/nhtechcon/async-rest-api
Skip to content
 
 

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

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

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages