AWS Lambda support for ASGI applications
Project description
Mangum
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
-
Event handlers for API Gateway HTTP and REST APIs, Application Load Balancer, Function URLs, and CloudFront Lambda@Edge.
-
Compatibility with ASGI application frameworks, such as Starlette, FastAPI, Quart and Django.
-
Support for binary media types and payload compression in API Gateway using GZip or Brotli.
-
Works with existing deployment and configuration tools, including Serverless Framework and AWS SAM.
-
Startup and shutdown lifespan events.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mangum-0.16.0.tar.gz
.
File metadata
- Download URL: mangum-0.16.0.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | afdf3799797696d849870ede07d4aedadb2df815019b1f469d3cabe45fb8e42e |
|
MD5 | 755744ee621032d8814933689c9b900e |
|
BLAKE2b-256 | aa49d1cd00401280e276f6328da1fe9ec2a2fc94d91ed507e41ddc9a101f9c82 |
Provenance
File details
Details for the file mangum-0.16.0-py3-none-any.whl
.
File metadata
- Download URL: mangum-0.16.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c687724d10504ae2570733a14b939479454268094309c596ef6cc1710e5029b0 |
|
MD5 | 931cf3385621a3f522e284f15e390794 |
|
BLAKE2b-256 | 9650818836c9d5adabd3eca7f586096b5f2bda18e4aff752d1362173ddd61105 |