-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi.py
45 lines (36 loc) · 1.02 KB
/
api.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
35
36
37
38
39
40
41
42
43
44
45
""" A module with two dawson-valid Python functions """
import json
from countrycode import countrycode
def myfunction(event, context):
""" This function is dawson-valid """
print(event, context)
return "Hello Function"
myfunction.api = {
"path": "test"
}
def myfunction2(event, context):
""" This function is dawson-valid """
print(event, context)
return { "hi": "Hello world JSON" }
myfunction2.api = {
"path": "test2",
"responseContentType": "application/json"
}
def myfunction3(event, context):
""" This function is dawson-valid """
print(event, context)
cc = countrycode(codes=['Algeria', 'United States'], origin='country_name', target='iso3c')
return ','.join(cc)
myfunction3.api = {
"path": "test3"
}
def myfunctionWithError(event, context):
""" This function is dawson-valid """
print(event, context)
raise Exception(json.dumps({
'httpStatus': 500,
'response': 'This function failed'
}))
myfunctionWithError.api = {
"path": "testError"
}