File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "name" : " plugin" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " Tencent Serverless Cloud Function example using Python" ,
5+ "main" : " index.py" ,
6+ "scripts" : {
7+ "test" : " echo \" Error: no test specified\" && exit 1"
8+ },
9+ "author" : " cloud.tencent.com" ,
10+ "license" : " MIT" ,
11+ "devDependencies" : {
12+ "serverless-tencent-scf-beta" : " ^0.1.7"
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ # -*- coding: utf8 -*-
2+
3+
4+ def product_get ():
5+ # todo: product_get action
6+ return {
7+ "result" : "it is product_get action"
8+ }
9+
10+
11+ def product_put ():
12+ # todo: product_put action
13+ return {
14+ "result" : "it is product_put action"
15+ }
16+
17+
18+ def main_handler (event , context ):
19+ print (str (event ))
20+ if event ["httpMethod" ] == "GET" :
21+ return product_get ()
22+ if event ["httpMethod" ] == "PUT" :
23+ return product_put ()
Original file line number Diff line number Diff line change 1+ service : plugin
2+
3+ provider :
4+ name : tencent
5+ runtime : Python3.6
6+ credentials : ~/credentials
7+ region : ap-singapore
8+
9+ plugins :
10+ - serverless-tencent-scf
11+
12+ functions :
13+ user_action_search :
14+ handler : user_action.student_get
15+ description : Tencent Serverless Cloud Function
16+ events :
17+ - apigw :
18+ name : user_action_apigw
19+ parameters :
20+ stageName : release
21+ serviceId :
22+ httpMethod : GET
23+ path : /user/student/
24+ enableCORS : true
25+ serviceTimeout : 10
26+ user_action_add :
27+ handler : user_action.teacher_put
28+ description : Tencent Serverless Cloud Function
29+ events :
30+ - apigw :
31+ name : user_action.teacher
32+ parameters :
33+ stageName : release
34+ serviceId :
35+ httpMethod : PUT
36+ path : /user/teacher/
37+ enableCORS : true
38+ serviceTimeout : 10
39+ product_action :
40+ handler : product_action.main_handler
41+ description : Tencent Serverless Cloud Function
42+ events :
43+ - apigw :
44+ name : product_action_apigw
45+ parameters :
46+ stageName : release
47+ serviceId :
48+ httpMethod : ANY
49+ path : /product/
50+ enableCORS : true
51+ serviceTimeout : 10
52+
Original file line number Diff line number Diff line change 1+ # -*- coding: utf8 -*-
2+
3+
4+ def student_get (event , context ):
5+ print (str (event ))
6+ # todo: student action
7+ return {
8+ "result" : "it is student_get action"
9+ }
10+
11+
12+ def teacher_put (event , context ):
13+ print (str (event ))
14+ # todo: teacher action
15+ return {
16+ "result" : "it is teacher_put action"
17+ }
You can’t perform that action at this time.
0 commit comments