Spaces:
Running
Running
File size: 974 Bytes
021c59c | 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 | """Local dev server for NIGHTWAVE -- NO gradio, Python 3.9 compatible.
Serves the raw radio document at GET "/" (top-level, NOT wrapped in an iframe)
so the browser grants mic + autoplay at the document root, plus the full
/api/* surface from server.create_api().
Run the whole radio + /api/* in mock mode locally with:
NIGHTWAVE_MOCK=1 python space/devserver.py
then open http://localhost:7860 in a browser. With MODAL_URL/MODAL_KEY/
MODAL_SECRET set (and NIGHTWAVE_MOCK unset) it proxies to the real Modal engine.
"""
import os
import uvicorn
from fastapi.responses import HTMLResponse
from server import create_api, read_radio_html
api = create_api()
@api.get("/", response_class=HTMLResponse)
def root_radio():
# Serve the raw radio doc directly (top-level) for local browser testing.
return HTMLResponse(read_radio_html())
if __name__ == "__main__":
port = int(os.environ.get("PORT", "7860"))
uvicorn.run(api, host="0.0.0.0", port=port)
|