DANGDOCAO's picture
Upload 16 files
2aec8e2 verified
raw
history blame
883 Bytes
from __future__ import annotations
import os
import threading
import webbrowser
from backend import create_app
app = create_app()
def _as_bool(value: str | None, default: bool) -> bool:
if value is None:
return default
return value.strip().lower() not in {"0", "false", "no", "off"}
def _open_browser_later(host: str, port: int) -> None:
if not _as_bool(os.getenv("HVU_OPEN_BROWSER"), True):
return
target_host = "127.0.0.1" if host in {"0.0.0.0", "::"} else host
url = f"http://{target_host}:{port}"
threading.Timer(1.2, lambda: webbrowser.open(url)).start()
if __name__ == "__main__":
host = os.getenv("HVU_HOST", "127.0.0.1")
port = int(os.getenv("HVU_PORT", "5000"))
debug = _as_bool(os.getenv("HVU_DEBUG"), False)
_open_browser_later(host, port)
app.run(host=host, port=port, debug=debug, use_reloader=False)