Documentation: https://erm.github.io/mangum/
Mangum is a library for using ASGI applications with FaaS platforms.
Python 3.6+
$ pip3 install mangum
Only two platforms are currently supported, but if you'd like to see others, please open an issue.
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.
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 application can be found here.
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]