forked from oracle-samples/oracle-functions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc.py
29 lines (24 loc) · 816 Bytes
/
func.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
#
# hello-python version 1.0.
#
# Copyright (c) 2020 Oracle, Inc. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
#
import io
import json
from fdk import response
def handler(ctx, data: io.BytesIO=None):
print("Entering Python Hello World handler", flush=True)
name = "World"
try:
body = json.loads(data.getvalue())
name = body.get("name")
except (Exception, ValueError) as ex:
print(str(ex), flush=True)
print("Vale of name = ", name, flush=True)
print("Exiting Python Hello World handler", flush=True)
return response.Response(
ctx, response_data=json.dumps(
{"message": "Hello {0}".format(name)}),
headers={"Content-Type": "application/json"}
)