blob: 5ad7329521d42e0b34b381bc2c19efe0f7015041 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
"""
Hub web application — serves the MeshBay SPA and static assets.
The SPA (Preact + htm) handles:
- Authentication (login, register, token refresh)
- Group discovery and browsing
- WebRTC connection to nodes for P2P file transfer
- Dark/light theme with system preference detection
Static files are served from meshbay_hub/static/ via Starlette StaticFiles.
The root route (/) returns the SPA HTML shell.
"""
from pathlib import Path
from fastapi import APIRouter
from fastapi.responses import HTMLResponse
STATIC_DIR = Path(__file__).parent.parent / "static"
router = APIRouter(tags=["webapp"])
@router.get("/app", response_class=HTMLResponse)
async def app_root():
return HTMLResponse(_HTML)
@router.get("/app/{path:path}", response_class=HTMLResponse)
async def app_catchall(path: str):
return HTMLResponse(_HTML)
@router.get("/", response_class=HTMLResponse)
async def index():
return HTMLResponse(_HTML)
_HTML = """\
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MeshBay</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div id="app"></div>
<script src="/keyderive.js"></script>
<script src="/crypto.js"></script>
<script src="/transport.js"></script>
<script type="module" src="/app.js"></script>
</body>
</html>
"""
|