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


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

Uploaded Source

File details

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

File metadata

  • Download URL: mangum-0.6.2.tar.gz
  • Upload date:
  • Size: 11.7 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.2.tar.gz
Algorithm Hash digest
SHA256 eabf105c94dcda0b7033e259f8bd55c9fad2814c30aa57ab759630e7e1341c06
MD5 42b4a849e5c3da05a6cd75374884d998
BLAKE2b-256 b2db3a0855cd11b830bb927425d0e3072891a0211382787cdd2f41560e0a8042

See more details on using hashes here.

Supported by

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