Skip to main content

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

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.20.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

asgikit-0.20.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file asgikit-0.20.0.tar.gz.

File metadata

  • Download URL: asgikit-0.20.0.tar.gz
  • Upload date:
  • Size: 23.5 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

Hashes for asgikit-0.20.0.tar.gz
Algorithm Hash digest
SHA256 01632d35cd8136088e1f9fba737e3cc8d1e656c18944a959d1c5bfa912f4c5af
MD5 f4bd9a02c599179b315ca4cd2f40741d
BLAKE2b-256 3591a479bc4fb777fe0e819a1f84877d3d54af5977c4b3c04d083a438dc448e5

See more details on using hashes here.

File details

Details for the file asgikit-0.20.0-py3-none-any.whl.

File metadata

  • Download URL: asgikit-0.20.0-py3-none-any.whl
  • Upload date:
  • Size: 18.3 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

Hashes for asgikit-0.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd7ed1c03c38ebd06734303d045c0be1e9e59334d4c65f7af85fd93efa66e9aa
MD5 6f3b6d4b8181639d3c4a16263dd16528
BLAKE2b-256 536347184657f6d38af603d02e026ef96a7e311aa971213f5a74296f2f3836ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page