description Mangum (Python) Overview
Mangum is a Python adapter that connects ASGI applications with AWS Lambda and other event-driven environments. It converts incoming platform events into the scope, receive, and send interactions expected by the ASGI specification, allowing frameworks such as FastAPI and Starlette to handle requests in a serverless deployment. It is intended for developers who want to run asynchronous Python web applications without a traditional long-lived server.
help Mangum (Python) FAQ
What problem does Mangum solve for FastAPI and Starlette?
Mangum adapts ASGI applications to AWS Lambda event sources such as API Gateway, Application Load Balancers, Function URLs, and Lambda@Edge. It lets frameworks such as FastAPI, Starlette, Quart, and Django handle requests without running a permanent Uvicorn server. [Mangum project](https://github.com/Kludex/mangum)
How is a FastAPI application wrapped with Mangum?
After creating the FastAPI application, the Lambda handler is typically declared as `handler = Mangum(app)`. AWS then invokes that handler with an event, and Mangum translates the event into the ASGI scope, receive, and send calls expected by FastAPI.
Can Mangum adapt a WSGI Flask application?
Mangum is an ASGI adapter, so it is intended for ASGI applications rather than ordinary WSGI Flask applications. A Flask project normally needs a WSGI-specific adapter or a deployment tool such as Zappa instead.
Does Mangum make local files permanent in AWS Lambda?
No, the Lambda runtime has a restricted filesystem and should not be treated as durable application storage. Mangum documentation warns about automatic directory creation for static files, so uploads and persistent assets normally belong in a service such as Amazon S3.
explore Explore More
Reviews & Comments
Write a Review
Be the first to review
Share your thoughts with the community and help others make better decisions.