Skip to main content

ASGI serverless adapters

Project description

Mangum

Documentation: https://erm.github.io/mangum/

Package version Build Status

Mangum is a library for using ASGI applications with FaaS platforms.

Requirements

Python 3.6+

Installation

$ pip3 install mangum

Dependencies

There are required/optional dependencies for specific platforms being used, but the base install does not have any hard requirements:

azure-functions - required for Azure Function support. Can be installed using:

$ pip3 install mangum[azure]

boto3, click - required for the AWS-specific CLI tools (this is NOT required in deployments):

$ pip3 install mangum[aws]

Everything can be installed with:

$ pip3 install mangum[full]

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 & AWS Gateway, wrap it in the AWSLambdaMiddleware:

# asgi.py

from mangum.platforms.aws.middleware import AWSLambdaMiddleware
from yourapp.app import app


handler = AWSLambdaMiddleware(app)  # optionally set debug=True

For this example, you would need to specify your lambda event handler as asgi.handler.

Note: This platform middleware can also use an optional debug argument to return unhandled errors raised by the application. It should NOT be enabled outside of development.

Azure Functions

Similarly as above, wrap the application using the AzureFunctionMiddleware:

from mangum.platforms.azure.middleware import AzureFunctionMiddleware
from yourapp.app import app

handler = AzureFunctionMiddleware(app)

A basic quickstart guide for using Azure Functions with Mangum is outlined here.

Mangum CLI (experimental)

Experimental AWS packaging/deployment support. This requires installation of the optional dependencies for AWS:

$ pip install mangum[full]

It also requires:

  • AWS CLI
  • AWS credentials.

The available commands are briefly outlined below, but there is also a quickstart guide here:

  • mangum aws init - Create a new configuration template for an application.

  • mangum aws build - Install the requirements and copy the application files into the build directory.

  • mangum aws package - Package the local project to prepare for deployment.

  • mangum aws deploy - Deploy the packaged application to AWS.

  • mangum aws tail - Tail the last 10 minutes of CloudWatch for the function.

  • mangum aws describe - Retrieve the API endpoints for the function.

  • mangum aws validate - Validate the SAM template in the current configuration.

Project details


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.5.7.tar.gz (11.3 kB view details)

Uploaded Source

File details

Details for the file mangum-0.5.7.tar.gz.

File metadata

  • Download URL: mangum-0.5.7.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.6.8rc1

File hashes

Hashes for mangum-0.5.7.tar.gz
Algorithm Hash digest
SHA256 4b4ff6df5e25431fcfa6c784e4779e5f13d8d2419779cf85e648dcb9bd497ea6
MD5 761c863c5f6930ef95fb6abf813b5c07
BLAKE2b-256 7e2d223b9f4440630ef29d60de7befe00201054152663c3a7260eb0504230767

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page