-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
59 lines (39 loc) · 1.21 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
52
53
54
55
56
57
58
59
from flask import Flask, render_template, Response,request,redirect,url_for,make_response,jsonify
from motion import VideoCameraMotion
import time
import itertools
too=itertools.cycle([True,False])
def foo():
return next(too)
def obj(o):
j=o.predictor()
return j
app = Flask(__name__)
app.config['SECRET_KEY'] = 'mysecretkey'
@app.route('/',methods=['GET', 'POST'])
@app.route('/index', methods = ['GET', 'POST'])
def index():
return render_template('index.html')
@app.route('/motion')
def motion():
return render_template('motion.html')
def gen(camera):
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
@app.route('/video_motion')
def video_motion():
return Response(gen(VideoCameraMotion()),mimetype='multipart/x-mixed-replace; boundary=frame')
@app.route('/instruction')
def instruction():
return render_template('instruction.html')
@app.route('/dashboard')
def dashboard():
return render_template('dashboard.html')
@app.route('/toogle')
def toogle():
VideoCameraMotion.flag=foo()
return redirect(url_for('index'))
if __name__ == '__main__':
app.run(debug=True)