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.21.0.tar.gz
(23.1 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.21.0-py3-none-any.whl
(18.0 kB
view details)
File details
Details for the file asgikit-0.21.0.tar.gz.
File metadata
- Download URL: asgikit-0.21.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.28.0 CPython/3.14.6 Linux/7.0.0-28-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5aa377cb9d375b0d3ddcb9524cd65379df7dad7656e6a71cce3850a30bbb0d18
|
|
| MD5 |
2a8d4341dc4d233233d32ab8914a4735
|
|
| BLAKE2b-256 |
5576fea8a963a3e82d07fcbc0ecbafb84d1f7776fde5dca0db2f4217a214aba1
|
File details
Details for the file asgikit-0.21.0-py3-none-any.whl.
File metadata
- Download URL: asgikit-0.21.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.28.0 CPython/3.14.6 Linux/7.0.0-28-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c2845b911668d2311b1403e7fe04dcac7ae41d8d2e571f4261faf217a67c17f
|
|
| MD5 |
88f788cfbe62b50a22da10853044209e
|
|
| BLAKE2b-256 |
fa0e5fc62447f90daf8f31c131b5b28271232f6d7980889965455802baf432da
|