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 http import HTTPMethod, HTTPStatus

from asgikit import Request


async def app(scope, receive, send):
    request = Request(scope, receive, send)

    # request method
    method = request.method

    if method not in (HTTPMethod.GET, HTTPMethod.POST):
        await request.respond_empty(HTTPStatus.METHOD_NOT_ALLOWED)
        return

    # request path
    path = request.path

    # request headers
    headers = request.headers

    # request query
    query = request.query

    # read body as json
    body_json = await request.body.read_json() if method == HTTPMethod.POST else None

    data = {
        "lang": "Python",
        "async": True,
        "platform": "asgi",
        "method": method,
        "path": path,
        "headers": dict(headers.items()),
        "query": dict(query.items()),
        "body": body_json,
    }

    # 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)
    await request.websocket.accept()

    while True:
        try:
            message = await request.websocket.read()
            await request.websocket.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.22.0.tar.gz (26.3 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.22.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: asgikit-0.22.0.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.28.1 CPython/3.14.6 Linux/7.0.0-30-generic

File hashes

Hashes for asgikit-0.22.0.tar.gz
Algorithm Hash digest
SHA256 0eb73dd0682452bbbdf6a6b7e72a52dbda6637b12acae77cdb0d9977869fea57
MD5 82f7999712ac2996287567d7fa4c253d
BLAKE2b-256 2388b4417da6a3976ba730c20a3f9f84587b7719011bba34d1bcbb6deee55309

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asgikit-0.22.0-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.28.1 CPython/3.14.6 Linux/7.0.0-30-generic

File hashes

Hashes for asgikit-0.22.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6303f8a1f954642f91a2973597fd3fca81cffedda9ab8ee5d1317e6d2c818b59
MD5 b874001b60c9de3ff50b66404d9b4ea3
BLAKE2b-256 6d704260433883dd2c91bda683a572321b453485f2ce4e157618d4cf1ad0bc67

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.22.0 This release

2 files

0.21.0

2 files

0.20.0

2 files

0.19.1

2 files

0.19.0

2 files

0.18.2

2 files

0.18.1

2 files

0.18.0

2 files

0.17.2

2 files

0.17.1

2 files

0.17.0

2 files

0.16.3

2 files

0.16.2

2 files

0.16.1

2 files

0.16.0

2 files

0.15.0

2 files

0.14.0

2 files

0.13.4

2 files

0.13.3

2 files

0.13.2

2 files

0.13.1

2 files

0.13.0

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.11.1

2 files

0.11.0

2 files

0.10.0

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.7.1

2 files

0.7.0

2 files

0.6.0

2 files

0.5.9

2 files

0.5.8

2 files

0.5.7

2 files

0.5.6

2 files

0.5.5

2 files

0.5.4

2 files

0.5.3

2 files

0.5.2

2 files

0.5.1

2 files

0.5.0

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page