ASGI serverless adapters
Project description
Mangum
Documentation: https://erm.github.io/mangum/
Mangum is a library for using ASGI applications with FaaS platforms.
Requirements
Python 3.6+
Installation
$ pip3 install mangum
Supported Platforms
Only two platforms are currently supported, but if you'd like to see others, please open an issue.
AWS Lambda / API Gateway
To make an ASGI application compatible with AWS Lambda & API Gateway, wrap it with the AWSLambdaAdapter
:
from mangum.platforms.aws.adapter import AWSLambdaAdapter
from yourapp.app import app
handler = AWSLambdaAdapter(app) # optionally set debug=True
You would then need to specify <path>.handler
in your AWS Lambda configuration.
Note: This platform adapter can also use an optional debug
argument to return unhandled errors raised by the application. It should NOT be enabled outside of development.
An example application can be found here.
Azure Functions
Similarly as above, wrap the application with the AzureFunctionAdapter
:
from mangum.platforms.azure.adapter import AzureFunctionAdapter
from yourapp.app import app
handler = AzureFunctionAdapter(app)
An example application can be found here.
Dependencies
The base install does not have any hard requirements, but there are dependencies required depending on platform:
azure-functions
- required for Azure Function support. Can be installed using:
$ pip3 install mangum[azure]
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.