Skip to main content

Python 3.6+ module to make Flask compatible with AWS Lambda

Project description

Write Flask applications that support being run in in AWS Lambda behind API Gateway.

This project was forked from: https://github.com/techjacker/flask-lambda

Improvements:

  • Expose original input event from AWS on Flask’s request object

  • Production-grade logging

Requirements

  • Python 3.6+

  • Flask 0.10+

Installation

pip install flask-lambda-support

Usage

Here is an example of what a Flask app using this library would look like:

from flask_lambda import FlaskLambda

app = FlaskLambda(__name__)


@app.route('/foo', methods=['GET', 'POST'])
def foo():
   data = {
       'form': request.form.copy(),
       'args': request.args.copy(),
       'json': request.json
   }
   return (
       json.dumps(data, indent=4, sort_keys=True),
       200,
       {'Content-Type': 'application/json'}
   )


if __name__ == '__main__':
    app.run(debug=True)

You can access the original input event and context on the Flask request context:

from flask import request

assert request.aws_event['input']['httpMethod'] == 'POST'
assert request.aws_context.get_remaining_time_in_millis() == 10_000

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_lambda_support-0.1.2-py36-none-any.whl (8.0 kB view details)

Uploaded Python 3.6

File details

Details for the file flask_lambda_support-0.1.2-py36-none-any.whl.

File metadata

  • Download URL: flask_lambda_support-0.1.2-py36-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3.6
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

File hashes

Hashes for flask_lambda_support-0.1.2-py36-none-any.whl
Algorithm Hash digest
SHA256 33f1a692ac5bd9e98acf11764a616b19323e7e372278e562488ddaa4b84d837b
MD5 aa1980f75d6bc26baf9e9d1b6dcfcf5b
BLAKE2b-256 c7456ee9c1c757ef5569dea9e26981eba0afe7e20fad0d1344f3466e9e904485

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page