{"id":7023,"library":"aws-wsgi","title":"AWS WSGI Adapter for Lambda/API Gateway","description":"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.","status":"deprecated","version":"0.2.7","language":"en","source_language":"en","source_url":"https://github.com/slank/awsgi","tags":["aws","lambda","api gateway","wsgi","flask","django","serverless"],"install":[{"cmd":"pip install aws-wsgi","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The primary interface is the 'awsgi' module itself, which contains the 'response' function.","symbol":"awsgi","correct":"import awsgi"}],"quickstart":{"code":"import awsgi\nfrom flask import Flask, jsonify, request\n\napp = Flask(__name__)\n\n@app.route('/')\ndef index():\n    return jsonify({\n        'message': 'Hello from aws-wsgi!',\n        'path': request.path,\n        'method': request.method\n    })\n\ndef lambda_handler(event, context):\n    return awsgi.response(app, event, context)\n\n# To test locally (e.g., with 'python -m flask run')\nif __name__ == '__main__':\n    app.run(debug=True)","lang":"python","description":"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`."},"warnings":[{"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`.","message":"The 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.","severity":"breaking","affected_versions":"All versions"},{"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.","message":"API 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"AWS Lambda has a 6MB payload limit for requests. Directly uploading large files via API Gateway and Lambda will hit this limit.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"WSGI applications deployed to AWS Lambda require explicit IAM permissions for the Lambda execution role to interact with other AWS services (e.g., S3, DynamoDB).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"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.","cause":"The `aws-wsgi` library or its dependencies are not correctly packaged or deployed within the Lambda environment, or the import path is incorrect.","error":"Unable to import module 'lambda_function': No module named 'awsgi'"},{"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.","cause":"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.","error":"500 Internal Server Error: 'wsgi.input' is not available"}]}