<# .SYNOPSIS Run the pricing dashboard so anyone on the same network can open it. .DESCRIPTION Binds Streamlit to every network interface and prints the URL to share. Streamlit only listens on this machine by default, which is why colleagues cannot reach it without this. The dashboard authenticates to COSMOS with the credentials in .env and shows live cost and margin data, so set a shared password before sharing the URL: $env:APP_PASSWORD = "something-not-guessable" Windows Firewall blocks the port for other machines until you allow it once, from an ELEVATED PowerShell: New-NetFirewallRule -DisplayName "Utopia Pricing Agent" ` -Direction Inbound -Protocol TCP -LocalPort 8501 ` -Action Allow -Profile Private Keep the rule on the Private profile. On a Public profile Windows treats the network as untrusted, and so should you. .PARAMETER Port Port to listen on. Default 8501. .EXAMPLE .\scripts\serve_lan.ps1 .\scripts\serve_lan.ps1 -Port 8080 #> [CmdletBinding()] param( [int]$Port = 8501, [string]$Python = "C:\Users\talha.ahmed\AppData\Local\anaconda3\envs\Talha\python.exe" ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $PSScriptRoot Set-Location $root if (-not (Test-Path $Python)) { throw "Python not found at $Python. Pass -Python ." } if (-not (Test-Path (Join-Path $root ".env"))) { Write-Warning ".env not found — COSMOS calls will fail. Copy .env.example and fill it in." } # The address colleagues type. Pick the real adapter, not WSL/Hyper-V virtual ones. $ip = Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254.*' -and $_.InterfaceAlias -notlike '*WSL*' -and $_.InterfaceAlias -notlike '*Default Switch*' -and $_.InterfaceAlias -notlike '*Hyper-V*' } | Select-Object -First 1 -ExpandProperty IPAddress if (-not $ip) { $ip = "" } $locked = [bool]$env:APP_PASSWORD Write-Host "" Write-Host " Utopia Pricing Agent" -ForegroundColor Cyan Write-Host " ---------------------------------------------" Write-Host " Share this URL: " -NoNewline Write-Host "http://${ip}:${Port}" -ForegroundColor Green Write-Host " On this machine: http://localhost:${Port}" if ($locked) { Write-Host " Password: set (APP_PASSWORD)" -ForegroundColor Green } else { Write-Host " Password: NOT SET - anyone on this network can read" -ForegroundColor Yellow Write-Host " live cost and margin data. Set APP_PASSWORD." -ForegroundColor Yellow } Write-Host " Stop with Ctrl+C" Write-Host "" & $Python -m streamlit run app.py ` --server.address 0.0.0.0 ` --server.port $Port ` --server.headless true