Registry / aws / aws-wsgi

aws-wsgi

JSON →
library0.2.7pypypi✓ verified 85d ago

aws-wsgi is a WSGI adapter that enables the use of WSGI-compatible Python frameworks (like Flask and Django) with AWS API Gateway's Lambda Proxy Integration. The project's GitHub repository was archived in March 2024, and its last release on PyPI was in July 2020. Users are encouraged to consider actively maintained forks like `awsgi2` or alternative solutions for new projects.

pip install aws-wsgi
INSTALL
IMPORT
SIG · AWS-WSGI
A
aws-wsgi
awspythonv0.2.7
Install
1.5s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.011s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.010s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

awsgi
import awsgi
The primary interface is the 'awsgi' module itself, which contains the 'response' function.

This quickstart demonstrates how to integrate a simple Flask application with `aws-wsgi` to run on AWS Lambda via API Gateway. The `lambda_handler` function serves as the entry point for AWS Lambda, passing the event and context to `awsgi.response`.

import awsgi from flask import Flask, jsonify, request app = Flask(__name__) @app.route('/') def index(): return jsonify({ 'message': 'Hello from aws-wsgi!', 'path': request.path, 'method': request.method }) def lambda_handler(event, context): return awsgi.response(app, event, context) # To test locally (e.g., with 'python -m flask run') if __name__ == '__main__': app.run(debug=True)
Debug
Known issues
breakingThe official `slank/awsgi` GitHub repository has been archived since March 13, 2024, and is now read-only. This indicates that the original project is no longer actively maintained.
fix
For new projects or continued maintenance, consider migrating to an actively maintained fork like `awsgi2` (`pip install awsgi2`) or an alternative serverless WSGI solution like `serverless-wsgi`.
affects: All versions
gotchaAPI Gateway requires proper `binaryMimeTypes` configuration to handle binary data (e.g., images, fonts). Without this, binary content might be base64 encoded and sent as text, leading to display issues in the client.
fix
Ensure that your API Gateway stages are configured with the correct `binaryMimeTypes` (e.g., `image/png`, `font/woff2`) and that your Lambda response correctly sets `isBase64Encoded` to true for binary content.
affects: All versions
gotchaAWS Lambda has a 6MB payload limit for requests. Directly uploading large files via API Gateway and Lambda will hit this limit.
fix
For file uploads exceeding 6MB, use AWS S3 pre-signed URLs to allow clients to directly upload files to S3, bypassing Lambda's payload limit.
affects: All versions
gotchaWSGI applications deployed to AWS Lambda require explicit IAM permissions for the Lambda execution role to interact with other AWS services (e.g., S3, DynamoDB).
fix
Verify that the IAM role associated with your Lambda function has all necessary permissions (e.g., `s3:GetObject`, `dynamodb:PutItem`) for any AWS services your application intends to access.
affects: All versions
Errors
Common errors & fixes
Unable to import module 'lambda_function': No module named 'awsgi'
The `aws-wsgi` library or its dependencies are not correctly packaged or deployed within the Lambda environment, or the import path is incorrect.
fix
Ensure `aws-wsgi` is included in your Lambda deployment package (e.g., in a layer or directly in the zip file). When using `pip`, install to a specific target directory: `pip install aws-wsgi -t ./python` and then zip the `python` directory.
500 Internal Server Error: 'wsgi.input' is not available
This generic WSGI error often indicates a malformed API Gateway event or an issue with how the adapter is attempting to read the request body, possibly due to unexpected content types or missing data.
fix
Verify the incoming API Gateway event structure matches the expected Lambda Proxy Integration format. Ensure clients are sending valid request bodies, especially for POST/PUT requests, and that appropriate `Content-Type` headers are set.
Upgrade
Version history
0.2.7latest on PyPI · released Jul 7, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
aws-wsgi — pip install aws-wsgi · libregistry