Skip to main content

AWS Lambda support for ASGI applications

Project description

Mangum

Package version 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.fastapiexpert.com/

Features

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

Uploaded Source

Built Distribution

mangum-0.18.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mangum-0.18.0.tar.gz
  • Upload date:
  • Size: 86.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for mangum-0.18.0.tar.gz
Algorithm Hash digest
SHA256 50179395012d9ae3df30484c16280decf0c56fb4c76bd6e1979b9b60135f254f
MD5 026d193aa9f83b61ae74dc1f4349b9d3
BLAKE2b-256 5f7b0297f416339ba43512bfeea976f5701cfe1ec06709b098c2e54c710aca57

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: mangum-0.18.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for mangum-0.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf71aa89bd655d465ece62c9c336be6b537eb297cfc72f7ea463aabc5eda2e6a
MD5 54c5ff54feb228a8a222b8f13ece8743
BLAKE2b-256 ef2596b21305063ff9cc609b2a50b178f9bff4dda4fc29e3ce6ce71b91f5c85d

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