-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathapp.py
31 lines (24 loc) · 831 Bytes
/
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
# Flask utils
from flask import Flask, redirect, url_for, request, render_template, Response
from werkzeug.utils import secure_filename
from gevent.pywsgi import WSGIServer
from face_verify import faceRec
camera = faceRec()
app = Flask(__name__)
@app.route("/")
def main():
return render_template("index.html")
def gen(camera):
while True:
frame = camera.main()
if frame != "":
global_frame = frame
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
@app.route('/video_feed')
def video_feed():
return Response(gen(camera), mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
# Serve the app with gevent
http_server = WSGIServer(('localhost', 5000), app)
http_server.serve_forever()