From 1b6b3aa9c88228b7a25f9562154ba1fbecc55ec3 Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 25 Sep 2021 19:26:04 +0100 Subject: [PATCH] 404 correctly on missing audio files. --- web_server.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web_server.py b/web_server.py index 142db8a..a66e147 100644 --- a/web_server.py +++ b/web_server.py @@ -426,7 +426,12 @@ async def audio_file(request, type: str, id: int): filename = get_normalised_filename_if_available(filename) # Send file or 404 - return await file(filename) + try: + response = await file(filename) + except FileNotFoundError: + abort(404) + return + return response # Static Files