Skip to main content

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

Development

You can publish a new version to PyPI with the following commands:

python3 setup.py sdist bdist_wheel
twine upload PATH_TO_WHL_FILE

[Refer to the official documentation on Python packaging for more information](https://packaging.python.org/tutorials/packaging-projects)

Metadata

Release files for flask-lambda-support 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for flask-lambda-support 0.1.5
File Interpreter ABI Platform
flask_lambda_support-0.1.5-py36-none-any.whl Python 3.6 none any Details

Release files / flask_lambda_support-0.1.5-py36-none-any.whl

Download URL flask_lambda_support-0.1.5-py36-none-any.whl
Size 10.5 kB
Tags Python 3.6
SHA-256 checksum
How to use checksums
20fb5699c3d2bc4adaddf093906547f31bb31f152a53da54bb077583fc3b67b4
BLAKE2b-256 checksum
How to use checksums
35b736bc9a6102bc4bd3fbc6c45eaf53d79188cd33cf56982c96b1b4b3fa2b23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.1.5 This release

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page