Files
2026-06-03 00:34:42 +08:00

41 lines
1.3 KiB
Batchfile

@echo off
cd /d "%~dp0"
echo Starting Speaking Lab server...
echo.
echo Website: http://127.0.0.1:8000
echo.
python -c "import fastapi, uvicorn, multipart" >nul 2>nul
if errorlevel 1 (
echo Missing dependencies. Installing now...
python -m pip install fastapi uvicorn python-multipart
if errorlevel 1 (
echo.
echo Dependency installation failed. Please check your Python installation.
pause
exit /b 1
)
)
start "Speaking Lab Server" cmd /k cd /d "%~dp0" ^&^& python -m uvicorn backend.main:app --reload --host 127.0.0.1 --port 8000
echo Waiting for the server to be ready...
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ready=$false; for($i=0; $i -lt 60; $i++){ try { $r=Invoke-WebRequest -Uri 'http://127.0.0.1:8000/api/videos' -UseBasicParsing -TimeoutSec 1; if($r.StatusCode -eq 200){ $ready=$true; break } } catch { Start-Sleep -Milliseconds 500 } }; if(-not $ready){ exit 1 }"
if errorlevel 1 (
echo.
echo Server did not start successfully.
echo Please check the "Speaking Lab Server" window for the error message.
pause
exit /b 1
)
echo Server is ready. Opening the website...
start "" "http://127.0.0.1:8000"
echo.
echo Website opened. Keep the "Speaking Lab Server" window open while using it.
echo You can close this window now.
pause