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
Metadata
Release files for asgikit 0.22.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asgikit-0.22.0.tar.gz | 26.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asgikit-0.22.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.8 kB
Release files / asgikit-0.22.0.tar.gz
| Download URL | asgikit-0.22.0.tar.gz |
|---|---|
| Size | 26.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0eb73dd0682452bbbdf6a6b7e72a52dbda6637b12acae77cdb0d9977869fea57
|
|
BLAKE2b-256 checksum How to use checksums |
2388b4417da6a3976ba730c20a3f9f84587b7719011bba34d1bcbb6deee55309
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.28.1 CPython/3.14.6 Linux/7.0.0-30-generic
|
Release files / asgikit-0.22.0-py3-none-any.whl
| Download URL | asgikit-0.22.0-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6303f8a1f954642f91a2973597fd3fca81cffedda9ab8ee5d1317e6d2c818b59
|
|
BLAKE2b-256 checksum How to use checksums |
6d704260433883dd2c91bda683a572321b453485f2ce4e157618d4cf1ad0bc67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.28.1 CPython/3.14.6 Linux/7.0.0-30-generic
|