Adds initial client-side api interface
This commit is contained in:
parent
15030d01c8
commit
823abb4395
1 changed files with 32 additions and 0 deletions
32
index.html
32
index.html
|
@ -28,4 +28,36 @@
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
async function getEndpoint(url = '') {
|
||||||
|
const response = await fetch(url, {method:'GET'});
|
||||||
|
const data = await response.json();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uiUpdate() {
|
||||||
|
window.setInterval(async () => {
|
||||||
|
data = await getEndpoint('http://127.0.0.1:5000/api/serverstatus');
|
||||||
|
document.getElementById("streamTitle").innerHTML = data.streamTitle
|
||||||
|
document.getElementById("currentViewers").innerHTML = data.viewerCount
|
||||||
|
document.getElementById("sessionMaxViewerCount").innerHTML = data.sessionMaxViewerCount
|
||||||
|
document.getElementById("overallMaxViewerCount").innerHTML = data.overallMaxViewerCount
|
||||||
|
document.getElementById("tags").innerHTML = data.tags
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateStreamTitle() {
|
||||||
|
response = await fetch('http://127.0.0.1:5000/api/update/streamtitle',
|
||||||
|
{
|
||||||
|
method:'POST',
|
||||||
|
data:JSON.stringify('a big test')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const data = await response.json()
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
// uiUpdate()
|
||||||
|
updateStreamTitle()
|
||||||
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue