diff --git a/app/doorboy-proxy.py b/app/doorboy-proxy.py index 559f412..fc1bac5 100755 --- a/app/doorboy-proxy.py +++ b/app/doorboy-proxy.py @@ -60,11 +60,11 @@ async def view_doorboy_uids(request): @app.route("/longpoll", stream=True) async def view_longpoll(request): - response = await request.respond(content_type="text/event-stream") key = request.headers.get("KEY") if not key or key not in [DOORBOY_SECRET_FLOOR, DOORBOY_SECRET_WORKSHOP]: return text("Invalid token") + response = await request.respond(content_type="text/event-stream") await response.send("data: response-generator-started\n\n") pipeline = [ { @@ -80,7 +80,9 @@ async def view_longpoll(request): if event["fullDocument"].get("type") == "open-door": await response.send("data: %s\n\n" % event["fullDocument"]["door"]) - except pymongo.errors.PyMongoError: + except pymongo.errors.PyMongoError as e: + print(e) + await response.send("data: response-generator-ended\n\n") return