Skip to content

Kludex/mangum

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8fb6100 · May 28, 2023
Mar 12, 2022
Nov 15, 2022
May 28, 2023
Feb 26, 2022
May 28, 2023
Jan 16, 2019
Oct 3, 2020
Oct 16, 2022
Nov 27, 2022
Mar 7, 2022
Oct 6, 2021
May 3, 2022
Apr 24, 2022
Feb 12, 2022
May 28, 2023
Feb 26, 2022
Nov 27, 2022

Repository files navigation

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")