mangum


Namemangum JSON
Version 0.19.0 PyPI version JSON
download
home_pageNone
SummaryAWS Lambda support for ASGI applications
upload_time2024-09-26 20:44:49
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Mangum

<a href="https://pypi.org/project/mangum/">
    <img src="https://badge.fury.io/py/mangum.svg" alt="Package version">
</a>
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/mangum.svg?style=flat-square">

Mangum is an adapter for running [ASGI](https://asgi.readthedocs.io/en/latest/) applications in AWS Lambda to handle Function URL, API Gateway, ALB, and Lambda@Edge events.

***Documentation***: https://mangum.fastapiexpert.com/

## Features

- Event handlers for API Gateway [HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) and [REST](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-rest-api.html) APIs, [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html), [Function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html), and [CloudFront Lambda@Edge](https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html).

- Compatibility with ASGI application frameworks, such as [Starlette](https://www.starlette.io/), [FastAPI](https://fastapi.tiangolo.com/), [Quart](https://pgjones.gitlab.io/quart/) and [Django](https://www.djangoproject.com/).

- Support for binary media types and payload compression in API Gateway using GZip or Brotli.

- Works with existing deployment and configuration tools, including [Serverless Framework](https://www.serverless.com/) and [AWS SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html).

- Startup and shutdown [lifespan](https://asgi.readthedocs.io/en/latest/specs/lifespan.html) events.

## Installation

```shell
pip install mangum
```

## Example

```python
from mangum import Mangum

async def app(scope, receive, send):
    await send(
        {
            "type": "http.response.start",
            "status": 200,
            "headers": [[b"content-type", b"text/plain; charset=utf-8"]],
        }
    )
    await send({"type": "http.response.body", "body": b"Hello, world!"})


handler = Mangum(app, lifespan="off")
```

Or using a framework:

```python
from fastapi import FastAPI
from mangum import Mangum

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}

handler = Mangum(app, lifespan="off")
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mangum",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Jordan Eremieff <jordan@eremieff.com>, Marcelo Trylesinski <marcelotryle@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/97/e0/6ee9bfa27226252a449cba12fc57d3f1c3ce661813377ab33e29245389a4/mangum-0.19.0.tar.gz",
    "platform": null,
    "description": "# Mangum\n\n<a href=\"https://pypi.org/project/mangum/\">\n    <img src=\"https://badge.fury.io/py/mangum.svg\" alt=\"Package version\">\n</a>\n<img alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/mangum.svg?style=flat-square\">\n\nMangum is an adapter for running [ASGI](https://asgi.readthedocs.io/en/latest/) applications in AWS Lambda to handle Function URL, API Gateway, ALB, and Lambda@Edge events.\n\n***Documentation***: https://mangum.fastapiexpert.com/\n\n## Features\n\n- Event handlers for API Gateway [HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html) and [REST](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-rest-api.html) APIs, [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html), [Function URLs](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html), and [CloudFront Lambda@Edge](https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html).\n\n- Compatibility with ASGI application frameworks, such as [Starlette](https://www.starlette.io/), [FastAPI](https://fastapi.tiangolo.com/), [Quart](https://pgjones.gitlab.io/quart/) and [Django](https://www.djangoproject.com/).\n\n- Support for binary media types and payload compression in API Gateway using GZip or Brotli.\n\n- Works with existing deployment and configuration tools, including [Serverless Framework](https://www.serverless.com/) and [AWS SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html).\n\n- Startup and shutdown [lifespan](https://asgi.readthedocs.io/en/latest/specs/lifespan.html) events.\n\n## Installation\n\n```shell\npip install mangum\n```\n\n## Example\n\n```python\nfrom mangum import Mangum\n\nasync def app(scope, receive, send):\n    await send(\n        {\n            \"type\": \"http.response.start\",\n            \"status\": 200,\n            \"headers\": [[b\"content-type\", b\"text/plain; charset=utf-8\"]],\n        }\n    )\n    await send({\"type\": \"http.response.body\", \"body\": b\"Hello, world!\"})\n\n\nhandler = Mangum(app, lifespan=\"off\")\n```\n\nOr using a framework:\n\n```python\nfrom fastapi import FastAPI\nfrom mangum import Mangum\n\napp = FastAPI()\n\n\n@app.get(\"/\")\ndef read_root():\n    return {\"Hello\": \"World\"}\n\n\n@app.get(\"/items/{item_id}\")\ndef read_item(item_id: int, q: str = None):\n    return {\"item_id\": item_id, \"q\": q}\n\nhandler = Mangum(app, lifespan=\"off\")\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "AWS Lambda support for ASGI applications",
    "version": "0.19.0",
    "project_urls": {
        "Changelog": "https://github.com/Kludex/mangum/blob/main/CHANGELOG.md",
        "Documentation": "https://mangum.fastapiexpert.com",
        "Funding": "https://github.com/sponsors/Kludex",
        "Homepage": "https://github.com/Kludex/mangum",
        "Source": "https://github.com/Kludex/mangum"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77ecdd1cae5f6b1b4a08c01de587b45e889036b2f8c06408621e0cb273909965",
                "md5": "f4a8fd6e6eaa2049d8d1e74fbe8e2a2e",
                "sha256": "e500b35f495d5e68ac98bc97334896d6101523f2ee2c57ba6a61893b65266e59"
            },
            "downloads": -1,
            "filename": "mangum-0.19.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4a8fd6e6eaa2049d8d1e74fbe8e2a2e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17083,
            "upload_time": "2024-09-26T20:44:48",
            "upload_time_iso_8601": "2024-09-26T20:44:48.357076Z",
            "url": "https://files.pythonhosted.org/packages/77/ec/dd1cae5f6b1b4a08c01de587b45e889036b2f8c06408621e0cb273909965/mangum-0.19.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97e06ee9bfa27226252a449cba12fc57d3f1c3ce661813377ab33e29245389a4",
                "md5": "4ee02566e6c5ea6dc5b0eed0efa62bff",
                "sha256": "e388e7c491b7b67970f8234e46fd4a7b21ff87785848f418de08148f71cf0bd6"
            },
            "downloads": -1,
            "filename": "mangum-0.19.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4ee02566e6c5ea6dc5b0eed0efa62bff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 85792,
            "upload_time": "2024-09-26T20:44:49",
            "upload_time_iso_8601": "2024-09-26T20:44:49.773793Z",
            "url": "https://files.pythonhosted.org/packages/97/e0/6ee9bfa27226252a449cba12fc57d3f1c3ce661813377ab33e29245389a4/mangum-0.19.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 20:44:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Kludex",
    "github_project": "mangum",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "mangum"
}
        
Elapsed time: 0.41843s