#!/usr/bin/env bash
# Local static explorer with SPA path fallback (/institution, /compare, /addresses/… → index.html).
# Usage: SERVE_BIND=0.0.0.0 ./scripts/serve-explorer-local.sh [port]
# Requires: Python 3.7+

set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PORT="${1:-8080}"
BIND="${SERVE_BIND:-127.0.0.1}"

if ! command -v python3 >/dev/null 2>&1; then
  echo "python3 required" >&2
  exit 1
fi

exec python3 "$SCRIPT_DIR/serve_explorer_spa.py" "$PORT" --bind "$BIND"
