Skip to content

denismakogon/simple-asgi

Repository files navigation

Simple ASGI HTTP 1.1 server implementation

This framework was inspired by hypercorn framework.

How to install

pip install simple-asgi

Example

import os
import socket


from simple_asgi import app
from simple_asgi import response
from simple_asgi import router


async def hello(request):
    request_body = await request.data
    return response.Response(body=request_body)

sock_path = "/tmp/fn.sock"
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

try:
    os.remove(sock_path)
finally:
    sock.bind("/tmp/fn.sock")

rtr = router.Router()
rtr.add("/call", ["POST"], hello)
http_app = app.SimpleASGI(name=__name__, router=rtr)

http_app.run(sock=sock)

About

Simple ASGI HTTP 1.1 server implementation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages