#!/bin/bash
# Simple script to serve the built app locally

if [ ! -d "dist" ]; then
    echo "Error: dist folder not found. Run 'npm run build' first."
    exit 1
fi

echo "Starting local server..."
echo "Open your browser to: http://localhost:8000"
echo "Press Ctrl+C to stop the server"
echo ""

# Try different server options in order of preference
if command -v python3 &> /dev/null; then
    python3 -m http.server 8000 --directory dist
elif command -v python &> /dev/null; then
    cd dist && python -m SimpleHTTPServer 8000
elif command -v php &> /dev/null; then
    php -S localhost:8000 -t dist
else
    echo "Error: No suitable HTTP server found."
    echo "Please install Python 3, Python 2, or PHP, or use 'npm run preview'"
    exit 1
fi
