ASGI serverless adapters
Project description
Mangum
Serverless response handlers for ASGI applications.
Work in progress
Currently supports AWS Lambda/API Gateway and Azure Functions. Experimental/unstable.
Requirements: Python 3.6+
Installation
pip install mangum
Note: The package on PyPi may be significantly behind the active development, so you probably want to clone the repo instead.
Example
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 lambda_handler(event, context):
return aws_handler(App, event, context)
Azure Functions
from mangum.handlers.azure import azure_handler
import azure.functions as func
def main(req):
response = azure_handler(App, req)
return func.HttpResponse(response["body"], status_code=response["status_code"])
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.2.tar.gz
(3.2 kB
view details)
File details
Details for the file mangum-0.2.2.tar.gz
.
File metadata
- Download URL: mangum-0.2.2.tar.gz
- Upload date:
- Size: 3.2 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 | 5c7cf50dbb809dea67c73dc0b691ab62773f16ec840698a551dfc4db78f085b8 |
|
MD5 | ccc39a8cd0a7ad826296c9efc4d6b979 |
|
BLAKE2b-256 | d614a52030f2683ec598cd17493f86697538c576bc7c80bd1b76f11bb712ae79 |