summaryrefslogtreecommitdiffhomepage
path: root/bin/serve
blob: cb6fb060da7655bc9e267eab76af9a8c2f4e0c3e (plain)
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
#!/usr/bin/env bash
# bin/serve — serve the web build locally
#
# Usage:
#   bin/serve          # serve on port 8080
#   bin/serve 9000     # serve on port 9000

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"

cd "$PROJECT_DIR"

BUILD_DIR="build-web"

if [ ! -f "$BUILD_DIR/index.html" ]; then
    echo "Error: Web build not found. Run 'bin/build-web' first." >&2
    exit 1
fi

PORT="${1:-8080}"

echo "Serving study-player at http://localhost:$PORT"
echo "Press Ctrl+C to stop."
python3 -m http.server "$PORT" -d "$BUILD_DIR"