-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
56 lines (47 loc) · 1.12 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
54
55
56
import flask
import os
import time
from flask import Flask, render_template, jsonify
health = True
ready = True
app = flask.Flask(__name__)
app.config["DEBUG"] = True
def current_milli_time():
return round(time.time() * 1000)
@app.route('/')
def index():
return render_template("index.html")
@app.route('/health')
def healthcheck():
if health:
return render_template("health.html")
else:
return 'bad request!', 400
@app.route('/sethealth')
def sethealth():
global health
health = False
chopstick = {
'health': health
}
return jsonify(chopstick)
@app.route('/ready')
def readycheck():
if ready:
return render_template("health.html")
else:
return 'bad request!', 400
@app.route('/setunready/<int:time_unv>')
def setunready(time_unv):
timer = current_milli_time()
global ready
ready = False
chopstick = {
'ready': ready
}
while current_milli_time() < timer + time_unv*1000:
ready = False
ready = True
return jsonify(chopstick)
if __name__ == "__main__":
app.run(host="0.0.0.0", debug=True, port="5000")