-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·53 lines (31 loc) · 1.16 KB
/
app.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
from flask import Flask, request, send_file, jsonify
import os
from pvt.test_report import report
from maps.handler import map_handler
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route("/pvt_data/<type>", methods = ["POST"])
def pvt_data(type):
content = request.json
reaction_times = content["reaction_times"]
test_times = content["test_times"]
false_clicks = content["false_clicks"]
if(len(reaction_times) == len(test_times) > 0):
# create a report class object
reporter = report(reaction_times, test_times, false_clicks)
# execute the requested method
if type == "summary":
return reporter.star_rate()
elif type == "chart":
plot = reporter.chart_times()
return send_file(plot, attachment_filename='plot.png', mimetype='image/png')
elif (len(reaction_times) == len(test_times) == 0):
return(jsonify({"rating": None, "comment": "insufficient data. please re-take the test", "level": None}))
else:
return(jsonify({"res": "invalid data"}))
@app.route('/map', methods = [ "POST"])
def map():
content = request.json
return(map_handler(content))
if __name__ == "__main__":
app.run(debug=True, host = "0.0.0.0")