Drops labdb's index.html / login.html / css / js into the binary via
embed.FS so the single 24 MB fivenode_go binary now ships both the
HTML/JS frontend AND the JSON API. No web server, no Apache,
no asset bundler.
hbrtl_ext/labdb_static/
public/ mirror of fivenode/labdb/public/
assets.go //go:embed public + two PRG-callable
HB_FUNCs: LABDB_STATIC_FILE(cPath) returns
the bytes, LABDB_STATIC_MIME(cPath)
returns the Content-Type derived from
the resolved (not raw) extension so "/"
-> text/html, not application/octet-stream.
app/bridge_server.prg
BridgeDispatch now falls through to the static FS for any path
that isn't /api/*. Missing assets get a 404 instead of being
routed to the path-to-symbol dispatcher.
Verified:
GET / -> 200 text/html, full index.html body
GET /login.html -> 200 text/html, 1850 bytes
GET /css/app.css -> 200 text/css
GET /api/admin-stats -> 200 JSON {devices:2,...} (still live PG)
GET /nonexistent.html -> 404 text/plain
Phase 1a complete: HTTP serves both the labdb frontend and the
real-data labdb API from one binary, end to end.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
1.8 KiB
HTML
56 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
|
<title>Sign In — labdb</title>
|
|
<link rel="stylesheet" href="/css/app.css?v=__V__">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container-sm">
|
|
<div class="login-card">
|
|
<h1>labdb</h1>
|
|
<div class="subtitle">Lab Data API · Admin</div>
|
|
|
|
<div id="errorBox" class="error-msg hidden"></div>
|
|
|
|
<form id="loginForm">
|
|
<div class="form-group">
|
|
<label>Username</label>
|
|
<input type="text" id="username" autocomplete="username" required autofocus>
|
|
</div>
|
|
<div class="form-group">
|
|
<label>Password</label>
|
|
<input type="password" id="password" autocomplete="current-password" required>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary" style="width:100%; justify-content:center;">Sign In</button>
|
|
</form>
|
|
</div>
|
|
<div class="footer">
|
|
© 2026 MEDiThings Inc. · labdb v1.0
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/js/api.js?v=__V__"></script>
|
|
<script>
|
|
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const errBox = document.getElementById('errorBox');
|
|
errBox.classList.add('hidden');
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
const result = await api.post('/api/admin/login', { username, password });
|
|
if (result.ok) {
|
|
location.href = '/';
|
|
} else {
|
|
errBox.textContent = (result.error && result.error.message) || result.error || 'Login failed';
|
|
errBox.classList.remove('hidden');
|
|
}
|
|
});
|
|
// auto-redirect if already logged in
|
|
api.get('/api/admin/me').then(r => { if (r.ok) location.href = '/'; });
|
|
</script>
|
|
</body>
|
|
</html>
|