From 42da24cb5e8f80b54613f2105cfb510a6a728570 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 21 Apr 2023 15:12:43 +0200 Subject: [PATCH] WebHost: offer room owner log download link --- WebHostLib/misc.py | 6 +++++- WebHostLib/templates/hostRoom.html | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/WebHostLib/misc.py b/WebHostLib/misc.py index bf9f4e2f..6d3e82c0 100644 --- a/WebHostLib/misc.py +++ b/WebHostLib/misc.py @@ -116,7 +116,11 @@ def display_log(room: UUID): if room is None: return abort(404) if room.owner == session["_id"]: - return Response(_read_log(os.path.join("logs", str(room.id) + ".txt")), mimetype="text/plain;charset=UTF-8") + file_path = os.path.join("logs", str(room.id) + ".txt") + if os.path.exists(file_path): + return Response(_read_log(file_path), mimetype="text/plain;charset=UTF-8") + return "Log File does not exist." + return "Access Denied", 403 diff --git a/WebHostLib/templates/hostRoom.html b/WebHostLib/templates/hostRoom.html index 6f02dc09..ba15d64a 100644 --- a/WebHostLib/templates/hostRoom.html +++ b/WebHostLib/templates/hostRoom.html @@ -32,13 +32,18 @@ {% endif %} {{ macros.list_patches_room(room) }} {% if room.owner == session["_id"] %} -
-
- - -
-
+
+
+
+ + +
+
+ + Open Log File... + +