-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
74 lines (63 loc) · 2.08 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/python
from flask import Flask, request
import os
app = Flask(__name__)
def add_header(args):
args.append('"Cookie: cookie"')
args.append('"X-Dispatch-Org: default"')
args.append('"accept: application/json"')
args.append('"content-type: application/json"')
@app.route('/v1/image')
def get_image():
args = ["curl -X GET http://localhost:8080/v1/image"]
add_header(args)
cmd = " -H ".join(args)
resp = os.popen(cmd).read()
return resp, 200, {'Access-Control-Allow-Origin': '*'}
@app.route('/v1/baseimage')
def get_baseimage():
args = ["curl -X GET http://localhost:8080/v1/baseimage"]
add_header(args)
cmd = " -H ".join(args)
resp = os.popen(cmd).read()
return resp, 200, {'Access-Control-Allow-Origin': '*'}
@app.route('/v1/function')
def get_function():
args = ["curl -X GET http://localhost:8080/v1/function"]
add_header(args)
cmd = " -H ".join(args)
resp = os.popen(cmd).read()
return resp, 200, {'Access-Control-Allow-Origin': '*'}
@app.route('/v1/api')
def get_api():
args = ["curl -X GET http://localhost:8080/v1/api"]
add_header(args)
cmd = " -H ".join(args)
resp = os.popen(cmd).read()
return resp, 200, {'Access-Control-Allow-Origin': '*'}
@app.route('/v1/event/drivers')
def get_event_driver():
args = ["curl -X GET http://localhost:8080/v1/event/drivers"]
add_header(args)
cmd = " -H ".join(args)
resp = os.popen(cmd).read()
return resp, 200, {'Access-Control-Allow-Origin': '*'}
@app.route('/v1/event/drivertypes')
def get_event_driver_type():
args = ["curl -X GET http://localhost:8080//v1/event/drivertypes"]
add_header(args)
cmd = " -H ".join(args)
resp = os.popen(cmd).read()
return resp, 200, {'Access-Control-Allow-Origin': '*'}
@app.route('/v1/runs', methods=['POST'])
def run():
function_name = request.args.get('functionName')
args = ["curl -X POST http://localhost:8080/v1/runs?functionName=" + function_name]
add_header(args)
args.append('"Accept-Encoding: gzip"')
cmd = " -H ".join(args)
cmd += " -d '%s'" % request.data
resp = os.popen(cmd).read()
return resp, 200, {'Access-Control-Allow-Origin': '*'}
if __name__ == '__main__':
app.run()