Simple ASGI HTTP 1.1 web server
Project description
# 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)
```
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)
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file simple_asgi-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: simple_asgi-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c641c636579560e39bcc9320e3192d7916dd067ffa8c95cf0d98f49c3800a09 |
|
MD5 | 8b6253567693559f05ef25c9623022e5 |
|
BLAKE2b-256 | 2968539fbaecbc4f6369b073b4e12f11a4476fd225adb639cada481ed077cfe1 |