https://github.com/denismakogon/simple-asgi
Simple ASGI HTTP 1.1 server implementation
https://github.com/denismakogon/simple-asgi
asgi asyncio http python3
Last synced: about 1 year ago
JSON representation
Simple ASGI HTTP 1.1 server implementation
- Host: GitHub
- URL: https://github.com/denismakogon/simple-asgi
- Owner: denismakogon
- License: apache-2.0
- Created: 2019-01-14T00:36:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-14T12:56:33.000Z (over 7 years ago)
- Last Synced: 2025-02-12T07:45:23.396Z (over 1 year ago)
- Topics: asgi, asyncio, http, python3
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple ASGI HTTP 1.1 server implementation
This framework was inspired by [hypercorn](https://pgjones.gitlab.io/hypercorn/index.html) framework.
## How to install
```bash
pip install simple-asgi
```
## Example
```python
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)
```