new debug server outline

This commit is contained in:
2023-06-11 01:32:21 +02:00
parent b8afaba4ef
commit ccb0ce87e1
4 changed files with 85 additions and 0 deletions

15
web/index.html Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>Centralex State</title>
<!--INSERT HEAD CONTENT HERE-->
</head>
<body>
<list id="list" />
</body>
</html>

3
web/main.css Normal file
View File

@@ -0,0 +1,3 @@
.body {
background-color: gray;
}

22
web/main.js Normal file
View File

@@ -0,0 +1,22 @@
window.onload = () => {
const evtSource = new EventSource("/events");
evtSource.addEventListener("change", event => {
console.log(event);
const newElement = document.createElement("li");
const eventList = document.getElementById("list");
newElement.textContent = `change at ${+event.data}`;
eventList.appendChild(newElement);
fetch("/data").then(res => res.json().then(res => console.log(res)));
});
evtSource.addEventListener("ping", event => {
console.log(event);
const newElement = document.createElement("li");
const eventList = document.getElementById("list");
newElement.textContent = `ping at ${+event.data}`;
eventList.appendChild(newElement);
});
};