Files
operating-room-monitor-server/start_demo_client.sh
2026-05-21 15:48:03 +08:00

36 lines
846 B
Bash
Executable File

#!/usr/bin/env bash
# Start the standalone demo client page for LAN access.
# Usage: ./start_demo_client.sh [port]
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
PORT="${1:-${DEMO_PORT:-38081}}"
HOST="${DEMO_HOST:-0.0.0.0}"
API_PORT="${API_PORT:-38080}"
LAN_IP="$(python3 - <<'PY'
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(("8.8.8.8", 80))
print(s.getsockname()[0])
except OSError:
print("")
finally:
s.close()
PY
)"
echo "Demo client listening on ${HOST}:${PORT}"
echo "Local: http://127.0.0.1:${PORT}/"
if [[ -n "${LAN_IP}" && ( "${HOST}" == "0.0.0.0" || "${HOST}" == "::" ) ]]; then
echo "LAN: http://${LAN_IP}:${PORT}/"
echo "Base URL: http://${LAN_IP}:${API_PORT}"
fi
exec python3 scripts/demo_client/server.py --host "$HOST" -p "$PORT"