Skip to content

Instantly share code, notes, and snippets.

@meyer1994
Last active January 23, 2020 14:18
Show Gist options
  • Save meyer1994/fa33730d2becf06e8ca18ba5fef3ad37 to your computer and use it in GitHub Desktop.
Save meyer1994/fa33730d2becf06e8ca18ba5fef3ad37 to your computer and use it in GitHub Desktop.
Flask in AWS Lambda
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/ping', methods=['GET'])
def ping():
return "pong"
@app.route('/echo', methods=['POST'])
def echo():
json = request.get_json()
return jsonify(json)
service: flasktest
provider:
name: aws
runtime: python3.8
plugins:
- serverless-wsgi
- serverless-python-requirements
package:
include:
- '!./**'
- './api.py'
exclude:
- '**'
functions:
api:
handler: wsgi_handler.handler
events:
- http: ANY /{path}
custom:
wsgi:
app: api.app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment