Check for jpg bytes before make_response

If jpg_bytes wasn't retrieved from either desk or a tracked object, respond with 404
Prevents uncaught error for unknown event ids sent to event_snapshot endpoint
This commit is contained in:
Craig Citro 2021-06-26 18:42:09 -05:00 committed by Blake Blackshear
parent 7ddba4fc59
commit 20912c12e7

View File

@ -214,6 +214,9 @@ def event_snapshot(id):
except:
return "Event not found", 404
if jpg_bytes is None:
return "Event not found", 404
response = make_response(jpg_bytes)
response.headers["Content-Type"] = "image/jpg"
return response