Skip to content

Commit

Permalink
WebHost: offer room owner log download link
Browse files Browse the repository at this point in the history
  • Loading branch information
Berserker66 committed Apr 28, 2023
1 parent 28c5e9e commit 42da24c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 5 additions & 1 deletion WebHostLib/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
19 changes: 12 additions & 7 deletions WebHostLib/templates/hostRoom.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@
{% endif %}
{{ macros.list_patches_room(room) }}
{% if room.owner == session["_id"] %}
<form method=post>
<div class="form-group">
<label for="cmd"></label>
<input class="form-control" type="text" id="cmd" name="cmd"
placeholder="Server Command. /help to list them, list gets appended to log.">
</div>
</form>
<div style="display: flex; align-items: center;">
<form method=post style="flex-grow: 1; margin-right: 1em;">
<div class="form-group">
<label for="cmd"></label>
<input class="form-control" type="text" id="cmd" name="cmd"
placeholder="Server Command. /help to list them, list gets appended to log.">
</div>
</form>
<a href="{{ url_for("display_log", room=room.id) }}">
Open Log File...
</a>
</div>
<div id="logger"></div>
<script type="application/ecmascript">
let xmlhttp = new XMLHttpRequest();
Expand Down

0 comments on commit 42da24c

Please sign in to comment.