Skip to main content

Python module to make Flask compatible with AWS Lambda for creating RESTful applications

Project description

Python module to make Flask compatible with AWS Lambda for creating RESTful applications.

Installation

pip install flask-lambda

Usage

This module works pretty much just like Flask. This allows you to run and develop this applicaiton locally just like you would in Flask. When ready deploy to Lambda, and configure the handler as:

my_python_file.app

Here is an example of what my_python_file.py 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)

API Gateway

Configure your API Gateway with a {proxy+} resource with an ANY method. Your “Method Response” should likely include an application/json “Response Body for 200” that uses the Empty model.

Deploying

Consider using python-mu.

Project details


Download files

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

Source Distribution

flask-lambda-0.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

flask_lambda-0.0.1-py2.py3-none-any.whl (3.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file flask-lambda-0.0.1.tar.gz.

File metadata

File hashes

Hashes for flask-lambda-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3d085da453c2caa9284aea0e74622cff49b7fa7fda9b4534dec1a9befe856a5b
MD5 d0dee2749790c5e68046aeae5206a50a
BLAKE2b-256 e68db0380f9c13fc4c13e8d8c6278f75a8f2f95fbaf11509fed9fd701adb58a8

See more details on using hashes here.

Provenance

File details

Details for the file flask_lambda-0.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for flask_lambda-0.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bd352a07152b462d77427055aeb139e9d7fb86d2be1f6f24f531f447f77f71d2
MD5 e837a8fbe8bd9a68928691ff5d6556d6
BLAKE2b-256 7f7f1859f55e1256c44c66311c900c8cb74b8fb34f295a2cfd07335bc3129516

See more details on using hashes here.

Provenance

Supported by

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