Implement session display

This commit is contained in:
Kai Vogelgesang 2020-04-17 02:18:24 +02:00
parent 0f23259e04
commit ee708e9127
3 changed files with 12 additions and 4 deletions

View File

@ -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)

View File

@ -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;
}
};

View File

@ -8,8 +8,10 @@
<body>
this is the UI
<!--<button id="test_api">Test API</button>-->
<br>
<span id="current_session">You are not in any session.</span>
<br>
<br>
<button id="btn_create_session">Create session</button>
<br><br><br>
<input id="join_session_id" type="text" placeholder="Enter session id" />
@ -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', {