-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
52 lines (38 loc) · 1.29 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
from lib.config import *
from lib.camera import *
from lib.switches import *
from flask import Flask, request, session, g, redirect, url_for, abort, \
render_template, flash, jsonify
import time
app = Flask(__name__)
conf = Config("camera.conf")
switches = Switches()
pic = PIC(conf.get_dictionary())
app.config.from_object(__name__)
@app.route('/')
def show_entries():
filelist = os.listdir(os.getcwd())
filelist = filter(lambda x: not os.path.isdir(x), filelist)
newest = max(filelist, key=lambda x: os.stat(x).st_mtime)
return render_template('index.html', path=newest)
@app.route('/take_photo')
def do_photo():
filename = pic.get_picture()
filename = filename.replace(conf.get_dictionary()['directory']+"/","")
# return render_template('image.html', path=filename)
data = {'filename': filename}
resp = jsonify(data)
resp.status_code =200
return resp
@app.route('/take_cv')
def do_cv2():
filename = pic.get_cv()
filename = filename.replace(conf.get_dictionary()['directory']+"/","")
return render_template('image.html', path=filename)
@app.route('/take_video')
def do_video():
filename = pic.get_video()
return render_template('video.html', path=filename)
if __name__ == '__main__':
app.debug = True
app.run(host="0.0.0.0")