-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
55 lines (47 loc) · 1.4 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
from gevent import monkey
monkey.patch_all()
from flask import Flask
from flask import render_template
from flask import request
from scripts import imageProcessing
from flask_socketio import SocketIO, emit
import sys
import time
import os
sys.path.append("/scripts/")
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
prod = 'PROD' in os.environ and os.environ['PROD'] in [1, 'true', 'True']
@app.route('/')
def index():
return render_template("index.html")
@app.route('/images/<filename>/')
def getImg(filename):
return app.send_static_file('images/' + filename)
@app.route('/data/facebank/<filename>/')
def getData(filename):
return app.send_static_file('data/facebank/' + filename)
@app.route('/dashboard/', methods=['GET'])
def dashboard():
if "command" in request.args:
command = request.args['command']
sendCommand(command)
return render_template('dashboard.html')
@socketio.on('channel-a')
def sendCommand(message):
print "SENDING COMMAND"
socketio.emit("channel-a", message)
if __name__ == '__main__':
app.debug = True
socketio.run(app, port=5000)
if prod:
print "Facial recognition status: ON"
imageProcessing.init(False)
pid = os.fork()
if pid == 0: # child processImage
while(True):
time.sleep(1.5)
imageProcessing.processImage()
else:
print "Facial recognition status: OFF"