-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
35 lines (27 loc) · 877 Bytes
/
index.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
from flask import Flask
from flask import render_template
from flask import jsonify
import subprocess
import credentials
import bashCommands
app = Flask(__name__)
@app.route('/', methods=['GET'])
def hello():
return render_template('index.html')
@app.route('/<cameraId>/<isRecording>', methods=['POST'])
def toggle_camera_recording(cameraId, isRecording):
try:
cameraId = int(cameraId[-1]) - 1
isRecording = (isRecording == 'true')
body = jsonify({'id': cameraId, 'isRecording': isRecording})
response = body
response.status_code = 200
bashCommands.ToggleRecord(0)
print(bashCommands.fileName)
if isRecording == False:
bashCommands.PlayVideo(bashCommands.fileName)
except Exception:
response.status_code = 500
finally:
return response
#app.run(host= '0.0.0.0')