From ee708e9127d9b8a1346256243a2bda3c1a628407 Mon Sep 17 00:00:00 2001 From: Kai Vogelgesang Date: Fri, 17 Apr 2020 02:18:24 +0200 Subject: [PATCH] Implement session display --- main.py | 4 +++- static/renderer.js | 4 ++++ ui.html | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 03fe7ea..9a891d9 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import aiohttp.web +import traceback from model import Model @@ -55,7 +56,8 @@ async def handler(request: aiohttp.web.Request): await model.ApiMethod.dict[method](model, client, **data) return aiohttp.web.Response(status=200) except Exception as e: - print(e) + del e # unused? + traceback.print_exc() return aiohttp.web.Response(status=400) diff --git a/static/renderer.js b/static/renderer.js index 55c613b..edc6e90 100644 --- a/static/renderer.js +++ b/static/renderer.js @@ -6,4 +6,8 @@ ws.onmessage = function(event) { const msg = JSON.parse(event.data); console.log(msg); + + if (msg.hasOwnProperty('session')) { + document.getElementById('current_session').innerText = msg.session; + } }; \ No newline at end of file diff --git a/ui.html b/ui.html index a54cad4..2ad2a56 100644 --- a/ui.html +++ b/ui.html @@ -8,8 +8,10 @@ this is the UI - - +
+You are not in any session. +
+



@@ -26,7 +28,7 @@ this is the UI }) }; document.getElementById("btn_join_session").onclick = async function (e) { - let text = document.getElementById("join_session_id").value + let text = document.getElementById("join_session_id").value; let data = {"sessionid": text}; await fetch('api/join_session', {