Toolkit for building ASGI applications and libraries
Project description
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 asgikit.requests import Request
async def main(scope, receive, send):
assert scope["type"] == "http"
request = Request(scope, receive, send)
# request method
method = request.method
# request path
path = request.path
# request headers
headers = request.headers
# read body as json
body = await request.read_json()
data = {
"lang": "Python",
"async": True,
"platform": "asgi",
"method": method,
"path": path,
"headers": dict(headers.items()),
"body": body,
}
# send json response
await request.respond_json(data)
Example websocket
from asgikit.exceptions import WebSocketDisconnect
from asgikit.websockets import WebSocket
async def app(scope, receive, send):
assert scope["type"] == "websocket"
ws = WebSocket(scope, receive, send)
await ws.accept()
while True:
try:
message = await ws.read()
await ws.write(message)
except WebSocketDisconnect:
print("Client disconnect")
break
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 Distribution
asgikit-0.16.1.tar.gz
(21.6 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.16.1-py3-none-any.whl
(16.9 kB
view details)
File details
Details for the file asgikit-0.16.1.tar.gz.
File metadata
- Download URL: asgikit-0.16.1.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.14.0 Linux/6.14.0-35-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27801964f34476d2e3621b137e511cb25e70a6187cb8e37817291f0536d82971
|
|
| MD5 |
d27e927da2d8b930a470e5ac32bab2d5
|
|
| BLAKE2b-256 |
69939cd6c8b669d50b40dc84337cbe344e75c0446e7487f50865bbcef4da1d72
|
File details
Details for the file asgikit-0.16.1-py3-none-any.whl.
File metadata
- Download URL: asgikit-0.16.1-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.1 CPython/3.14.0 Linux/6.14.0-35-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b536048977ee626d72ea42c06cedfb7ed6c2dfdd37de515bd6132ccea2a3490
|
|
| MD5 |
d190ce14e7815faf3aebc240f432eb1a
|
|
| BLAKE2b-256 |
863b6b0822a0c13174685175dc3d5ecbf51fcf120e98301c84308afd00f81e80
|