fix exception when file does not exist

fixes https://git.clan.lol/clan/clan-core/issues/488
This commit is contained in:
Jörg Thalheim
2023-11-14 16:55:01 +01:00
parent 8b42d0207a
commit f65bd8aa85
2 changed files with 12 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ async def root(path_name: str) -> Response:
if not filename.is_file():
log.error("File not found: %s", filename)
return Response(status_code=404)
else:
return Response(status_code=404)
content_type, _ = guess_type(filename)
return Response(filename.read_bytes(), media_type=content_type)