From b90df4386327221dbf14acdddd2ca9706f0cdb41 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 23 Jul 2022 16:58:56 +0200 Subject: stringify path before passing it to FileResponse Depending on the Python version, this might raise an error: Before 3.8, mimetypes.guess_type could not deal with a pathlib.Path, and only accepted a string. guess_type is called internally by FileResponse, so to make sure we don't run into errors, we stringify the path before passing it to FileResponse. --- fietsboek/views/detail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fietsboek/views/detail.py b/fietsboek/views/detail.py index 34d392b..80d112b 100644 --- a/fietsboek/views/detail.py +++ b/fietsboek/views/detail.py @@ -119,7 +119,7 @@ def image(request): except FileNotFoundError: return HTTPNotFound() else: - return FileResponse(image_path, request) + return FileResponse(str(image_path), request) @view_config(route_name="add-comment", request_method="POST", permission="track.comment") -- cgit v1.2.3