Created
August 29, 2022 11:20
-
-
Save 7h3h4ckv157/3eee6c2968004edabdbfa9a6b64b5ab5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2019 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
"""App Engine app to serve as an endpoint for App Engine queue samples.""" | |
# [START cloud_tasks_appengine_quickstart] | |
from flask import Flask, render_template, request | |
app = Flask(__name__) | |
@app.route('/example_task_handler', methods=['POST']) | |
def example_task_handler(): | |
"""Log the request payload.""" | |
payload = request.get_data(as_text=True) or '(empty payload)' | |
print('Received task with payload: {}'.format(payload)) | |
return render_template("index.html", payload=payload) | |
# [END cloud_tasks_appengine_quickstart] | |
@app.route('/') | |
def hello(): | |
"""Basic index to verify app is serving.""" | |
return 'Hello World!' | |
if __name__ == '__main__': | |
# This is used when running locally. Gunicorn is used to run the | |
# application on Google App Engine. See entrypoint in app.yaml. | |
app.run(host='127.0.0.1', port=8080, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment