-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_server.ps1
More file actions
31 lines (25 loc) · 983 Bytes
/
Copy pathstart_server.ps1
File metadata and controls
31 lines (25 loc) · 983 Bytes
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
$env:PYTHONPATH = "C:\Users\123\Desktop\f2-xiaohongshu-changes\f2"
Set-Location "C:\Users\123\Desktop\f2-xiaohongshu-changes\f2"
Write-Host "Starting backend server..."
Write-Host "Press Ctrl+C to stop the server"
Write-Host ""
$process = Start-Process -FilePath "python" -ArgumentList "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000" -PassThru -WindowStyle Normal
Write-Host "Server started with PID: $($process.Id)"
Write-Host "Waiting for server to be ready..."
Start-Sleep -Seconds 3
if (-not $process.HasExited) {
Write-Host "Server is running on http://localhost:8000"
Write-Host "Press Ctrl+C to stop the server"
try {
while (-not $process.HasExited) {
Start-Sleep -Seconds 1
}
}
finally {
Write-Host "`nStopping server..."
Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
Write-Host "Server stopped."
}
} else {
Write-Host "Server failed to start!"
}