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
Close
Hashes for flask_lambda_support-0.1.3-py36-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1ead3969c3a761b5a1442a450c30ddcf08a8396f70c4094a60b8a51cabb18df |
|
MD5 | bd7f92556dd4054db036073087c4d0ca |
|
BLAKE2b-256 | 7e3f26f7a00906eb333c05870e45fe76805e7eb7e25dd9b9741443183e00ff5a |