#!/usr/bin/env bash
# Simple HTTP server for testing Lux web examples
# Usage: ./serve.sh [port]

PORT=${1:-8080}
DIR="$(dirname "$0")"

echo "Serving Lux web examples at http://localhost:$PORT"
echo "Open http://localhost:$PORT/index.html in your browser"
echo "Press Ctrl+C to stop"
echo ""

cd "$DIR"

# Try python3 first, then python, then node
if command -v python3 &> /dev/null; then
    python3 -m http.server $PORT
elif command -v python &> /dev/null; then
    python -m SimpleHTTPServer $PORT
elif command -v npx &> /dev/null; then
    npx serve -p $PORT .
else
    echo "Error: No suitable HTTP server found."
    echo "Install Python or Node.js to serve files."
    exit 1
fi
