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 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.body.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 import Request, WebSocketDisconnect
async def app(scope, receive, send):
if scope["type"] != "websocket":
return
request = Request(scope, receive, send)
ws = await request.upgrade()
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.18.2.tar.gz
(23.4 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.18.2-py3-none-any.whl
(18.2 kB
view details)
File details
Details for the file asgikit-0.18.2.tar.gz.
File metadata
- Download URL: asgikit-0.18.2.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.14.3 Linux/6.17.0-19-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a78792fd6ccfc077e98ca5d9ae6c19ad1bea383bdbc3c40a0fa1b49e2c61d5d
|
|
| MD5 |
4b1ab036923d771fbb2fd02bdf3e0fac
|
|
| BLAKE2b-256 |
b7ae8cf985359fe00f19a38b15ff9a8cef3af33e3f540c0f07cf53842664d70c
|
File details
Details for the file asgikit-0.18.2-py3-none-any.whl.
File metadata
- Download URL: asgikit-0.18.2-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.14.3 Linux/6.17.0-19-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e46af9ca6d4e56443fc5e28bb6aaec8cbd0cb2659675a4293e4f8391d5dd91ee
|
|
| MD5 |
537236e7bf696a04178e377ad58bbe92
|
|
| BLAKE2b-256 |
c949a28da393375a286d650a88e6cb12a743a70d4f8a6583c0799fef90099463
|