QuizFrog/start.ps1

42 lines
1.7 KiB
PowerShell

$ROOT = Split-Path -Parent $MyInvocation.MyCommand.Path
Write-Host "==============================" -ForegroundColor Cyan
Write-Host " QuizFrog Starting..." -ForegroundColor Cyan
Write-Host "==============================" -ForegroundColor Cyan
Write-Host ""
# Start backend (hidden window)
Write-Host "[1/2] Starting backend (port 8000)..." -ForegroundColor Yellow
$PythonPath = "$ROOT\backend\venv\Scripts\python.exe"
Start-Process cmd -ArgumentList "/c", "cd /d `"$ROOT\backend`" && `"$PythonPath`" -m uvicorn app.main:app --reload --port 8000 --host 0.0.0.0" -WindowStyle Hidden
Start-Sleep -Seconds 8
# Start frontend (hidden window)
Write-Host "[2/2] Starting frontend (port 3000)..." -ForegroundColor Yellow
Start-Process cmd -ArgumentList "/c", "cd /d `"$ROOT\frontend`" && npm run dev -- --hostname 0.0.0.0" -WindowStyle Hidden
Start-Sleep -Seconds 5
# Get LAN IP
$LAN_IP = Get-NetIPAddress -AddressFamily IPv4 | Where-Object {
$_.InterfaceAlias -notmatch "Loopback|WSL|Hyper-V|Virtual|Bluetooth" -and
$_.IPAddress -notmatch "^(127|169\.254)\."
} | Select-Object -First 1 -ExpandProperty IPAddress
Write-Host ""
Write-Host "==============================" -ForegroundColor Green
Write-Host " All services started!" -ForegroundColor Green
Write-Host ""
Write-Host " Local: http://localhost:3000" -ForegroundColor White
Write-Host " LAN: http://${LAN_IP}:3000" -ForegroundColor White
Write-Host " API: http://localhost:8000/docs" -ForegroundColor White
Write-Host "==============================" -ForegroundColor Green
Write-Host ""
# Open browser
Start-Process "http://localhost:3000"
Write-Host "Press any key to exit..." -ForegroundColor Gray
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | Out-Null