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

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 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.

Azure Functions

Similarly as above, wrap the application using the AzureFunctionAdapter:

from mangum.platforms.azure.adapter import AzureFunctionAdapter
from yourapp.app import app

handler = AzureFunctionAdapter(app)

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

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]

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

Uploaded Source

File details

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

File metadata

  • Download URL: mangum-0.6.1.tar.gz
  • Upload date:
  • Size: 11.6 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.6.1.tar.gz
Algorithm Hash digest
SHA256 b7f7b7cab3855280dcb920f7b1289a23ad5d70d0cfedcb28f415c96cf8d235a4
MD5 ec7c925281f14f52860453ddb2b8c0e6
BLAKE2b-256 344a0c42f4337e6cac94391e1de8c2a3c1d07429b6c308bad8f9f679dd37f34f

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