-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_web_app.ps1
More file actions
54 lines (47 loc) · 1.61 KB
/
start_web_app.ps1
File metadata and controls
54 lines (47 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$ErrorActionPreference = "Stop"
Set-Location -Path $PSScriptRoot
$port = 8001
if ($args.Count -gt 0 -and $args[0] -ne "--check") {
$port = [int]$args[0]
}
$pythonExe = "python"
if (Test-Path ".\.venv\Scripts\python.exe") { $pythonExe = ".\.venv\Scripts\python.exe" }
if (Test-Path ".\venv\Scripts\python.exe") { $pythonExe = ".\venv\Scripts\python.exe" }
if ($args.Count -gt 0 -and $args[0] -eq "--check") {
Write-Host "PROJECT_DIR=$PWD"
Write-Host "PYTHON_EXE=$pythonExe"
Write-Host "DEFAULT_PORT=8001"
exit 0
}
try {
$null = & $pythonExe --version
} catch {
Write-Host "Python not found. Please install Python or create venv/.venv first."
Read-Host "Press Enter to exit"
exit 1
}
$lanIp = $null
try {
$lanIp = Get-NetIPAddress -AddressFamily IPv4 |
Where-Object { $_.IPAddress -notlike '169.254*' -and $_.InterfaceAlias -notmatch 'Loopback|vEthernet|VirtualBox|VMware' } |
Select-Object -First 1 -ExpandProperty IPAddress
} catch {
$lanIp = $null
}
if ([string]::IsNullOrWhiteSpace($lanIp)) { $lanIp = "127.0.0.1" }
Write-Host ""
Write-Host "=============================="
Write-Host "Microbial Colony Counter Web App Launcher"
Write-Host "Project: $PWD"
Write-Host "Python: $pythonExe"
Write-Host "Local URL: http://127.0.0.1:$port/"
Write-Host "LAN URL: http://$lanIp`:$port/"
Write-Host "=============================="
Write-Host ""
& $pythonExe -m uvicorn backend.main:app --host 0.0.0.0 --port $port
if ($LASTEXITCODE -ne 0) {
Write-Host ""
Write-Host "Startup failed. Check port usage or dependency installation."
Read-Host "Press Enter to exit"
exit 1
}