-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (29 loc) · 1.13 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import functions_framework
from markupsafe import escape
# Local dictionary to store terms and their definitions
definitions = {
'ccv': 'Center for Computation and Visualization',
'python': 'A high-level programming language.','bu': 'brown university',
'json': 'JavaScript Object Notation, a lightweight data interchange format.',
# Add more terms and definitions as needed
}
@functions_framework.http
def hello_http(request):
"""HTTP Cloud Function.
Args:
request (flask.Request): The request object.
<https://flask.palletsprojects.com/en/1.1.x/api/#incoming-request-data>
Returns:
The response text, or any set of values that can be turned into a
Response object using `make_response`
<https://flask.palletsprojects.com/en/1.1.x/api/#flask.make_response>.
"""
request_json = request.get_json(silent=True)
request_args = request.args
if request_json and "name" in request_json:
name = request_json["name"]
elif request_args and "name" in request_args:
name = request_args["name"]
else:
name = "World"
return f"Hello {escape(name)}!"