Adds initial client-side api interface

This commit is contained in:
Ariana Giroux 2022-07-22 17:15:56 -06:00
parent 15030d01c8
commit 823abb4395
1 changed files with 32 additions and 0 deletions

View File

@ -28,4 +28,36 @@
</footer>
</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>