Merge branch 'master' of leafbla.de:dominic/webpnp
This commit is contained in:
commit
b90858b5cb
4
main.py
4
main.py
@ -1,4 +1,5 @@
|
|||||||
import aiohttp.web
|
import aiohttp.web
|
||||||
|
import traceback
|
||||||
|
|
||||||
from model import Model
|
from model import Model
|
||||||
|
|
||||||
@ -55,7 +56,8 @@ async def handler(request: aiohttp.web.Request):
|
|||||||
await model.ApiMethod.dict[method](model, client, **data)
|
await model.ApiMethod.dict[method](model, client, **data)
|
||||||
return aiohttp.web.Response(status=200)
|
return aiohttp.web.Response(status=200)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
del e # unused?
|
||||||
|
traceback.print_exc()
|
||||||
return aiohttp.web.Response(status=400)
|
return aiohttp.web.Response(status=400)
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,4 +6,8 @@ ws.onmessage = function(event) {
|
|||||||
const msg = JSON.parse(event.data);
|
const msg = JSON.parse(event.data);
|
||||||
|
|
||||||
console.log(msg);
|
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>
|
<body>
|
||||||
this is the UI
|
this is the UI
|
||||||
|
<br>
|
||||||
<!--<button id="test_api">Test API</button>-->
|
<span id="current_session">You are not in any session.</span>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
<button id="btn_create_session">Create session</button>
|
<button id="btn_create_session">Create session</button>
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
<input id="join_session_id" type="text" placeholder="Enter session id" />
|
<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) {
|
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};
|
let data = {"sessionid": text};
|
||||||
|
|
||||||
await fetch('api/join_session', {
|
await fetch('api/join_session', {
|
||||||
|
Loading…
Reference in New Issue
Block a user