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

Uploaded Source

Built Distribution

mangum-0.19.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mangum-0.19.0.tar.gz
Algorithm Hash digest
SHA256 e388e7c491b7b67970f8234e46fd4a7b21ff87785848f418de08148f71cf0bd6
MD5 4ee02566e6c5ea6dc5b0eed0efa62bff
BLAKE2b-256 97e06ee9bfa27226252a449cba12fc57d3f1c3ce661813377ab33e29245389a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mangum-0.19.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 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.19.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e500b35f495d5e68ac98bc97334896d6101523f2ee2c57ba6a61893b65266e59
MD5 f4a8fd6e6eaa2049d8d1e74fbe8e2a2e
BLAKE2b-256 77ecdd1cae5f6b1b4a08c01de587b45e889036b2f8c06408621e0cb273909965

See more details on using hashes here.

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