-
Notifications
You must be signed in to change notification settings - Fork 0
/
web_app.py
73 lines (58 loc) · 2.1 KB
/
web_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
from flask import Flask, request, render_template, Response, \
send_from_directory
from motion_detect import m_d
import time
from datetime import datetime
from database import db_session
from database_handler import getLastSetting, setNewSetting
app = Flask(__name__)
startTime = datetime.now()
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.png',
mimetype='image/vnd.microsoft.icon')
@app.route("/")
def homePage():
return render_template("welcome.html")
@app.route("/liveFeed")
def liveFeed():
return render_template("liveFeed.html")
@app.route("/settings")
def settings():
return render_template("settings.html", currentSettings=getLastSetting())
@app.route("/settings", methods=['POST'])
def my_form_post():
setNewSetting(request.form['displayTimestamp'],
request.form['displayBoundaries'],
request.form['analysisMode'],
request.form['useYOLO'],
request.form.get('area1', 'False'),
request.form.get('area2', 'False'),
request.form.get('area3', 'False'),
request.form['sensitivity'],
request.form['maxTicks'])
return render_template("settings.html", currentSettings=getLastSetting())
@app.route("/about")
def about():
return render_template("about.html",runtime=getRuntime(),
currentSettings=getLastSetting())
@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
def getRuntime():
return datetime.now() - startTime
def gen():
global m_d
while True:
#frame = m_d.output_frame
time.sleep(1)
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + m_d.output_frame + b'\r\n')
@app.route('/video_feed')
def video_feed():
return Response(gen(),
mimetype='multipart/x-mixed-replace; boundary=frame')
def start():
app.run(debug=False, use_reloader=False, host="0.0.0.0", port=8080)