Skip to main content

Toolkit for building ASGI applications and libraries

Reason this release was yanked:

Incompatible with previous semantic version

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


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.17.2.tar.gz (23.2 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.17.2-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asgikit-0.17.2.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.2 CPython/3.14.0 Linux/6.14.0-36-generic

File hashes

Hashes for asgikit-0.17.2.tar.gz
Algorithm Hash digest
SHA256 13b10d0cf86f553d1a95b3046d681c6f023795ffb94652c2c149ea4d74c0c9da
MD5 01fa07274b4c30e8f776bcc25bc286e9
BLAKE2b-256 4af923dcfffdb66b51232fef5b07a8f5bd705f9cc46d80309954293a998d3d72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asgikit-0.17.2-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.2 CPython/3.14.0 Linux/6.14.0-36-generic

File hashes

Hashes for asgikit-0.17.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c923f192b6886dea759791687e9ecaea4d45dbd89273b0190f5843ac8c59b544
MD5 6e67b0c4f24f6dd74768bf7b8011eb4e
BLAKE2b-256 6bde4f3455ab93c5d49815f0e8eb3624f04897e039e36e5ddf09268738a7283a

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