-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (41 loc) · 1.19 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
from camera import Video
import flask as fsk
app = fsk.Flask(__name__)
@app.route('/')
def index():
return fsk.render_template('index.html')
position = "NULL"
area = "NULL"
def gen(camera):
while True:
global position
global area
global ball
frame, position, area, ball = camera.main_exec()
yield (b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/video_feed')
def video_feed():
return fsk.Response(gen(Video()),mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/status')
def status():
present = "FALSE"
global area
if area != '0.0' and area!="NULL":
if " %" not in area:
area+=" %"
else:
area = "NULL"
if (position!="NULL"):
present = "TRUE"
else:
present = "FALSE"
print(present, position, area)
return fsk.jsonify(present = present, position = position, area = area)
@app.route('/font')
def font():
filename = 'static/Azonix.otf'
return fsk.send_file(filename, mimetype='font/otf')
@app.route('/github')
def github():
return fsk.redirect("https://github.com/hariketsheth/TCR_Task_1")
app.run(debug=True)