Files

36 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""SDR recordings browser (stdlib only). Recordings only -- no mode switching.
Run: python3 -I /opt/pi/sdr/web/server.py (port SDR_WEB_PORT, default 8090)
GET / single-page UI (sticky player, filters, live refresh)
GET /api/list ?voice=1|0 &limit=N -> {items:[...], pending:n, status:{...}}
GET /api/recent ?limit=N &group=G &noise=1 (backward compatible list)
GET /api/status scanner health (unit state, last recording, files/hour)
GET /api/mode legacy alias: {"mode": "scanner"|"off", ...}
GET /audio/DAY/FILE MP3 with HTTP Range support (falls back to DAY/noise/FILE); ?dl=1 -> download
GET /audio/DAY/noise/FILE classifier-rejected recording
GET /s/<token>[/data|/a/N] public share page of one conversation
"""
import os
import sys
import threading
from http.server import ThreadingHTTPServer
# `python3 -I` implies -P (no script dir on sys.path), so put the package root (the parent of web/) there ourselves.
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from radio.config import PORT # noqa: E402
from web import events # noqa: E402
from web.handler import H # noqa: E402
def main():
ThreadingHTTPServer.daemon_threads = True
threading.Thread(target=events.watch, name="watch", daemon=True).start()
ThreadingHTTPServer(("0.0.0.0", PORT), H).serve_forever()
if __name__ == "__main__":
main()