Add Pi Zero headless serial bridge with AP portal and daily RTC-based logs
This commit is contained in:
45
templates/serial.html
Normal file
45
templates/serial.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user