AWS Lambda & API Gateway support for ASGI
Project description
Mangum
Mangum is an adapter for using ASGI applications with AWS Lambda & API Gateway. It is intended to provide an easy-to-use, configurable wrapper for any ASGI application deployed in an AWS Lambda function to handle API Gateway requests and responses.
Documentation: https://mangum.io/
Features
-
Multiple storage backend interfaces for managing WebSocket connections.
-
Compatibility with ASGI application frameworks, such as Starlette, FastAPI, and Quart.
-
Support for binary media types and payload compression in API Gateway.
-
Works with existing deployment and configuration tools, including Serverless Framework and AWS SAM.
-
Startup and shutdown lifespan events.
Requirements
Python 3.6+
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)
or using a framework:
from mangum import Mangum
from starlette.applications import Starlette
from starlette.responses import PlanTextResponse
from starlette.routing import Route
async def homepage(request):
response = PlainTextResponse("Hello, world!")
return response
app = Starlette(debug=True, routes=[Route("/", homepage)])
handler = Mangum(app)
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
File details
Details for the file mangum-0.9.1.tar.gz
.
File metadata
- Download URL: mangum-0.9.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebca962c5b072ed46646a90e5c51bb9d4aa0fb74ddd6837a2bb68a7f26c210b2 |
|
MD5 | 51c7ffbe177625a45034fc680e942847 |
|
BLAKE2b-256 | e2e9446826a667d305271da0de2b82833d961b3a3aba84a4f4025ed95f396a4f |