-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
41 lines (32 loc) · 1.15 KB
/
application.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
import sys
from flask import Flask, request
from flask import render_template
app = Flask(__name__)
def scenario(args):
return args['scenario'] if 'scenario' in args else 'hello_world'
@app.route('/', methods=['GET'])
def index():
# return the rendered template
return render_template("index.html", coordinator=sys.argv[1], maintenance=sys.argv[2], scenario=scenario(request.args))
@app.route('/test', methods=['GET'])
def index_test():
# return the rendered template
return render_template("index.html", coordinator=sys.argv[1], maintenance="false", scenario=scenario(request.args))
@app.route('/pirates', methods=['GET'])
def pirates():
# return the rendered template
return render_template("pirates.html", coordinator=sys.argv[1], maintenance="false")
@app.route('/health', methods=['GET'])
def health():
return 'OK'
@app.route('/files/<path:filepath>', methods=['GET'])
def files(filepath):
with open("agent/examples/{}".format(filepath), "r") as f:
content = f.read()
return content
if __name__ == '__main__':
try:
app.run(host='0.0.0.0')
except RuntimeError:
print("Exiting")
pass