AWS WSGI Adapter for Lambda/API Gateway

0.2.7 · deprecated · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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)

view raw JSON →