#!/bin/bash

# EwizPro Website Development Server
# Simple script to start a local development server

echo "🚀 Starting EwizPro Development Server..."
echo "📂 Serving from: $(pwd)"
echo ""

# Try different ports in case one is already in use
PORTS=(8080 8000 3000 5000 8888)

for PORT in "${PORTS[@]}"; do
    echo "🔍 Trying port $PORT..."
    
    # Check if port is available
    if ! lsof -i :$PORT > /dev/null 2>&1; then
        echo "✅ Port $PORT is available!"
        echo "🌐 Your website will be available at:"
        echo "   http://localhost:$PORT"
        echo ""
        echo "📱 Press Ctrl+C to stop the server"
        echo "─────────────────────────────────────────"
        
        # Start the server
        python3 -m http.server $PORT
        
        # If we reach here, server was stopped
        echo "✋ Server stopped."
        exit 0
    else
        echo "❌ Port $PORT is already in use"
    fi
done

echo "😞 All common ports are in use. Try closing other applications or use a specific port:"
echo "   python3 -m http.server [PORT_NUMBER]"
