mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
add health check and handle bad camera names
This commit is contained in:
parent
f148eb5a7b
commit
39d64f7ba7
@ -66,21 +66,32 @@ def main():
|
|||||||
# create a flask app that encodes frames a mjpeg on demand
|
# create a flask app that encodes frames a mjpeg on demand
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def ishealthy():
|
||||||
|
# return a healh
|
||||||
|
return "Frigate is running. Alive and healthy!"
|
||||||
|
|
||||||
@app.route('/<camera_name>/best_person.jpg')
|
@app.route('/<camera_name>/best_person.jpg')
|
||||||
def best_person(camera_name):
|
def best_person(camera_name):
|
||||||
best_person_frame = cameras[camera_name].get_best_person()
|
if camera_name in cameras:
|
||||||
if best_person_frame is None:
|
best_person_frame = cameras[camera_name].get_best_person()
|
||||||
best_person_frame = np.zeros((720,1280,3), np.uint8)
|
if best_person_frame is None:
|
||||||
ret, jpg = cv2.imencode('.jpg', best_person_frame)
|
best_person_frame = np.zeros((720,1280,3), np.uint8)
|
||||||
response = make_response(jpg.tobytes())
|
ret, jpg = cv2.imencode('.jpg', best_person_frame)
|
||||||
response.headers['Content-Type'] = 'image/jpg'
|
response = make_response(jpg.tobytes())
|
||||||
return response
|
response.headers['Content-Type'] = 'image/jpg'
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
return f'Camera named {camera_name} not found', 404
|
||||||
|
|
||||||
@app.route('/<camera_name>')
|
@app.route('/<camera_name>')
|
||||||
def mjpeg_feed(camera_name):
|
def mjpeg_feed(camera_name):
|
||||||
# return a multipart response
|
if camera_name in cameras:
|
||||||
return Response(imagestream(camera_name),
|
# return a multipart response
|
||||||
mimetype='multipart/x-mixed-replace; boundary=frame')
|
return Response(imagestream(camera_name),
|
||||||
|
mimetype='multipart/x-mixed-replace; boundary=frame')
|
||||||
|
else:
|
||||||
|
return f'Camera named {camera_name} not found', 404
|
||||||
|
|
||||||
def imagestream(camera_name):
|
def imagestream(camera_name):
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user