From c590ce7c1798e73d41769d79a516cd1d533d8e24 Mon Sep 17 00:00:00 2001 From: Peri Date: Thu, 4 Jun 2020 11:32:58 +0700 Subject: [PATCH] Hello flask --- cloud-function/main.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cloud-function/main.py diff --git a/cloud-function/main.py b/cloud-function/main.py new file mode 100644 index 0000000000..e14e3d9aba --- /dev/null +++ b/cloud-function/main.py @@ -0,0 +1,20 @@ +from flask import Flask, request +app = Flask(__name__) + +@app.route('/hello', methods=['POST']) +def hello_world(): + """Responds to any HTTP request. + Args: + request (flask.Request): HTTP request object. + Returns: + The response text or any set of values that can be turned into a + Response object using + `make_response `. + """ + request_json = request.get_json() + if request.args and 'message' in request.args: + return request.args.get('message') + elif request_json and 'message' in request_json: + return request_json['message'] + else: + return f'Hello World2!'