-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
executable file
·71 lines (47 loc) · 1.77 KB
/
server.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
import requests,json, os
from flask import Flask, request, render_template, send_file, make_response, jsonify
from myErrVisualizer import MyErrVisualizer
app = Flask(__name__)
headers = {'Content-Type' : 'application/json'}
# @app.errorhandler(403)
# @app.errorhandler(404)
# @app.errorhandler(410)
# @app.errorhandler(500)
# def MyErrVisualizerErr(e):
# return "\nDon't TRY AGAIN or else you will be BLOCKED!!!\n"
@app.route('/life', methods=["GET"])
def LiveGET():
return json.dumps('I\'m Alive!')
@app.route('/', methods=["GET"])
def MyErrVisualizerGET():
# return json.dumps("Welcome to MyErrVisualizer!")
return render_template('index.html', name='13')
@app.route('/MyErrVisualizer', methods=["POST"])
def MyErrVisualizerPOST():
os.system('clear')
if request.method == "POST":
json_dict = request.get_json()
Traces, TracesLines = {}, []
try:
Traces = json_dict['Traces']
print("="*10)
print("Found Traces as follows: \n\n{}\n".format(Traces))
print("="*10)
TracesLines = Traces.split('\n')
print("\nTracesLines: {}".format(TracesLines))
myEV = MyErrVisualizer(TracesLines, cloud_mode=True)
print("\nMyEV.Cloud_Output: {}".format(myEV.cloud_output))
return jsonify(myEV.cloud_output)
except:
print("*** NO Traces could be Found, Aborting...")
return """<html><body>
Cannot Find 'Traces' field
</body></html>"""
return jsonify('correctData')
else:
return """<html><body>
Invalid JSON Data
</body></html>"""
if __name__ == '__main__':
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0',port=port,threaded=True,debug=True)