46 lines
1.1 KiB
HTML
46 lines
1.1 KiB
HTML
<!doctype html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Serial Stream</title>
|
|
<link rel="stylesheet" href="/static/style.css">
|
|
</head>
|
|
<body>
|
|
<main class="container">
|
|
<h1>ESP32 Serial Live</h1>
|
|
<p><a href="/">Zurück zum WLAN-Portal</a></p>
|
|
<pre id="terminal" class="terminal"></pre>
|
|
</main>
|
|
|
|
<script>
|
|
const term = document.getElementById('terminal');
|
|
const maxLines = 500;
|
|
const lines = [];
|
|
|
|
function appendLine(text) {
|
|
lines.push(text);
|
|
if (lines.length > maxLines) {
|
|
lines.shift();
|
|
}
|
|
term.textContent = lines.join('\n');
|
|
term.scrollTop = term.scrollHeight;
|
|
}
|
|
|
|
const events = new EventSource('/events/serial');
|
|
events.onmessage = (evt) => {
|
|
try {
|
|
const payload = JSON.parse(evt.data);
|
|
appendLine(payload.line || '');
|
|
} catch (e) {
|
|
appendLine(evt.data || '');
|
|
}
|
|
};
|
|
|
|
events.onerror = () => {
|
|
appendLine('[sse] reconnecting...');
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|