Skip to main content

ASGI to AWS Lambda adapter

Project description

mangum

An attempt to provide simple AWS Lambda support to any ASGI application.

Work in progress.

Example

from mangum import asgi_response


class App:
    def __init__(self, scope) -> None:
        self.scope = scope

    async def __call__(self, receive, send) -> None:
        message = await receive()
        if message["type"] == "http.request":
            await send(
                {
                    "type": "http.response.start",
                    "status": 200,
                    "headers": [[b"content-type", b"text/plain"]],
                }
            )
            await send({"type": "http.response.body", "body": b"Hello, world!"})


def lambda_handler(event, context):
    return asgi_response(App, event, context)

Todo

  • WebSocket support through API Gateway
  • Chunked responses/streaming
  • Tests
  • Detailed instructions

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

mangum-0.0.2.tar.gz (2.6 kB view details)

Uploaded Source

File details

Details for the file mangum-0.0.2.tar.gz.

File metadata

  • Download URL: mangum-0.0.2.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for mangum-0.0.2.tar.gz
Algorithm Hash digest
SHA256 96c3b9d051621efa716fd22981ccba55f39254c4e09e0cd37f6abaf49f8e6cff
MD5 d12e6d9190d2188b43037d3d2ca1f46d
BLAKE2b-256 1f9a053d3ff8c69e35bb86d99745d41dfddbb01cf24a00d09b80b41bb1575185

See more details on using hashes here.

Provenance

Supported by

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