<#
.SYNOPSIS
Runs a local HTTP server for the US County Climate Explorer.

.DESCRIPTION
Starts Python's built-in HTTP server from the project root so the browser can
load data/climate-data.csv and related static assets over http://localhost.

.PARAMETER Port
The localhost port to bind. Defaults to 8000.

.EXAMPLE
.\serve.ps1
#>
[CmdletBinding()]
param(
  [int]$Port = 8000
)

$ErrorActionPreference = "Stop"

$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$VenvPython = Join-Path $ProjectRoot ".venv\Scripts\python.exe"
$PythonCommand = if (Test-Path $VenvPython) { $VenvPython } else { "python" }

Set-Location $ProjectRoot

Write-Host "Serving US County Climate Explorer at http://localhost:$Port/"
Write-Host "Press Ctrl+C to stop."

& $PythonCommand -m http.server $Port --bind 127.0.0.1
