Asgikit - ASGI Toolkit
Asgikit is a toolkit for building asgi applications and frameworks.
The examples directory contain usage examples of several use cases
Features:
- Request
- Headers
- Cookies
- Body (bytes, str, json, form, stream)
- Form
- Response
- Plain text
- Json
- Streaming
- File
- Websockets
Example request and response
from http import HTTPMethod, HTTPStatus
from asgikit import Request
async def app(scope, receive, send):
request = Request(scope, receive, send)
# request method
method = request.method
if method not in (HTTPMethod.GET, HTTPMethod.POST):
await request.respond_empty(HTTPStatus.METHOD_NOT_ALLOWED)
return
# request path
path = request.path
# request headers
headers = request.headers
# request query
query = request.query
# read body as json
body_json = await request.body.read_json() if method == HTTPMethod.POST else None
data = {
"lang": "Python",
"async": True,
"platform": "asgi",
"method": method,
"path": path,
"headers": dict(headers.items()),
"query": dict(query.items()),
"body": body_json,
}
# send json response
await request.respond_json(data)
Example websocket
from asgikit import Request, WebSocketDisconnect
async def app(scope, receive, send):
if scope["type"] != "websocket":
return
request = Request(scope, receive, send)
await request.websocket.accept()
while True:
try:
message = await request.websocket.read()
await request.websocket.write(message)
except WebSocketDisconnect:
print("Client disconnect")
break
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asgikit-0.22.0.tar.gz
(26.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
asgikit-0.22.0-py3-none-any.whl
(21.5 kB
view details)
File details
Details for the file asgikit-0.22.0.tar.gz.
File metadata
- Download URL: asgikit-0.22.0.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
pdm/2.28.1 CPython/3.14.6 Linux/7.0.0-30-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0eb73dd0682452bbbdf6a6b7e72a52dbda6637b12acae77cdb0d9977869fea57
|
|
| MD5 |
82f7999712ac2996287567d7fa4c253d
|
|
| BLAKE2b-256 |
2388b4417da6a3976ba730c20a3f9f84587b7719011bba34d1bcbb6deee55309
|
File details
Details for the file asgikit-0.22.0-py3-none-any.whl.
File metadata
- Download URL: asgikit-0.22.0-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
pdm/2.28.1 CPython/3.14.6 Linux/7.0.0-30-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6303f8a1f954642f91a2973597fd3fca81cffedda9ab8ee5d1317e6d2c818b59
|
|
| MD5 |
b874001b60c9de3ff50b66404d9b4ea3
|
|
| BLAKE2b-256 |
6d704260433883dd2c91bda683a572321b453485f2ce4e157618d4cf1ad0bc67
|