Skip to content
/ lsgi Public

Simple AWS Lambda WSGI adapter with a focus on AWS SAM support

License

Notifications You must be signed in to change notification settings

mathom/lsgi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LSGI

LSGI (Lambda Serverless Gateway Interface) is a simple WSGI adapter for AWS Lambda. The main goal is to provide a simple way to get your WSGI apps running under Lambda using the AWS SAM toolchain.

Installation

For now you can install this directly from the repo:

pip install git+https://github.com/mathom/lsgi.git

Usage

Import LSGI in your app (in the example this is named app.py) and add a handler for Lambda:

import lsgi
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, World!"

def lambda_handler(event, context):
    return lsgi.handler(app, event, context)

To deploy this with AWS SAM, try this template:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'

Resources:
  TestFlask:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: app.lambda_handler
      Runtime: python3.6
      CodeUri: .
      Events:
        Root:
          Type: Api
          Properties:
            Path: /
            Method: ANY
Outputs:
  ApiEndpoint:
    Description: HTTP API endpoint
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"

Related projects

About

Simple AWS Lambda WSGI adapter with a focus on AWS SAM support

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages