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.0.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.0-py3-none-any.whl
(16.7 kB
view details)
File details
Details for the file asgikit-0.16.0.tar.gz.
File metadata
- Download URL: asgikit-0.16.0.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 |
c8464121574c6bbdc3a3bb65148cf19e224935ca1fa6bc0847fa71892d41f8a3
|
|
| MD5 |
fab178a8891d58eb8c523d5f3a330df3
|
|
| BLAKE2b-256 |
153b099b3dd74c18cb7830602ad076f175ce294b04bebcd5b8a9cd549c6bc3a0
|
File details
Details for the file asgikit-0.16.0-py3-none-any.whl.
File metadata
- Download URL: asgikit-0.16.0-py3-none-any.whl
- Upload date:
- Size: 16.7 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 |
723c3b6bd5e5e81468d2ff2bd782e7e71ae414303bcdc54404a598c33dca94a4
|
|
| MD5 |
e1c3b30a3eb8cff9890f25ba424e0d9f
|
|
| BLAKE2b-256 |
38c04311462862f44500f9287a2aa140dc0a6ba9153f61f493c85abbc94ddba1
|