Implement session display
This commit is contained in:
parent
0f23259e04
commit
ee708e9127
4
main.py
4
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)
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
8
ui.html
8
ui.html
@ -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', {
|
||||
|
Loading…
Reference in New Issue
Block a user