Skip to content
forked from slank/awsgi

A WSGI gateway for the AWS API Gateway/Lambda proxy integration

Notifications You must be signed in to change notification settings

advian-oss/awsgi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 

Repository files navigation

AWSGI

AWSGI allows you to use WSGI-compatible middleware and frameworks like Flask and Django with the AWS API Gateway/Lambda proxy integration.

Replaced by an improved fork awsgi2.

Installation

awsgi2 is available from PyPI as awsgi2:

pip install awsgi2

Examples

Flask

import awsgi2
from flask import (
    Flask,
    jsonify,
)

app = Flask(__name__)


@app.route('/')
def index():
    return jsonify(status=200, message='OK')


def lambda_handler(event, context):
    return awsgi2.response(app, event, context, base64_content_types={"image/png"})

Django

import os
import awsgi2

from django.core.wsgi import get_wsgi_application

# my_app_directory/settings.py is a vanilla Django settings file, created by "django-admin startproject".
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_app_directory.settings')
# In the settings.py file, you may find it useful to include this setting to remove
# Django's need for SQLite, which is currently (2020-11-17) outdated in the Lambda runtime image
# DATABASES = { 'default': { 'ENGINE': 'django.db.backends.dummy', } }

application = get_wsgi_application()

def lambda_handler(event, context):
    return awsgi2.response(application, event, context, base64_content_types={"image/png"})

About

A WSGI gateway for the AWS API Gateway/Lambda proxy integration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.3%
  • Makefile 1.7%