ASGI serverless adapters
Project description
Mangum
Mangum is a library for adapting ASGI applications to use on FaaS platforms.
Important: This project is under active development and in an experimental/unstable state.
Supported Platforms
- AWS Lambda + API Gateway
- Azure Functions
Requirements
Python 3.6+
Installation
pip3 install mangum
Example
Below is a basic ASGI application example that can be used with handler methods:
class App:
def __init__(self, scope) -> None:
self.scope = scope
async def __call__(self, receive, send) -> None:
message = await receive()
if message["type"] == "http.request":
await send(
{
"type": "http.response.start",
"status": 200,
"headers": [[b"content-type", b"text/plain"]],
}
)
await send({"type": "http.response.body", "body": b"Hello, world!"})
AWS Lambda + API Gateway
from mangum.handlers.aws import aws_handler
def asgi_handler(event, context):
return aws_handler(App, event, context)
Azure Functions
from mangum.handlers.azure import azure_handler
def asgi_handler(req):
return azure_handler(App, req)
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
mangum-0.2.6.tar.gz
(3.7 kB
view details)
File details
Details for the file mangum-0.2.6.tar.gz
.
File metadata
- Download URL: mangum-0.2.6.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c997fd7afb8f1e4d6c22e2df326aeb056bb2241c430f0fb95ea5f8cc59288cb0 |
|
MD5 | 0312da25bfb1b2d47c729c6026d25ed7 |
|
BLAKE2b-256 | 00d91336c27f32d06efe36e4fb6c113c48fcaf4ed2a289be1dcf039b52dfbbf6 |