Skip to main content

AWS Lambda support for ASGI applications

Project description

Mangum

Package version Build Status PyPI - Python Version

Mangum is an adapter for running ASGI applications in AWS Lambda to handle Function URL, API Gateway, ALB, and Lambda@Edge events.

Documentation: https://mangum.io/

Features

Requirements

Python 3.7+

Installation

pip install mangum

Example

from mangum import Mangum

async def app(scope, receive, send):
    await send(
        {
            "type": "http.response.start",
            "status": 200,
            "headers": [[b"content-type", b"text/plain; charset=utf-8"]],
        }
    )
    await send({"type": "http.response.body", "body": b"Hello, world!"})


handler = Mangum(app, lifespan="off")

Or using a framework:

from fastapi import FastAPI
from mangum import Mangum

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}

handler = Mangum(app, lifespan="off")

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

Uploaded Source

Built Distribution

mangum-0.15.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mangum-0.15.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.12

File hashes

Hashes for mangum-0.15.0.tar.gz
Algorithm Hash digest
SHA256 12e84806198b23bbd5a54b9b69c1aef3c62177347219bb57c8ec114b8a6b8537
MD5 a9b27dd39df3e5dafe04bcc06b6f61fe
BLAKE2b-256 e539d42e42eded512ad9e0bb97a7b5dec96a2b262cdcff6b61fb78eabfd15316

See more details on using hashes here.

Provenance

File details

Details for the file mangum-0.15.0-py3-none-any.whl.

File metadata

  • Download URL: mangum-0.15.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.12

File hashes

Hashes for mangum-0.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfd0e59ca8102be119b00b0d65894fcead8184438ecfa3110f87c7d2d9c90f01
MD5 221db72a257bd301d6a59c8b96531ae1
BLAKE2b-256 4674456c74ccdfe9b9aaea4ae22535647961972da33c7466eb8b905e244bdd41

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