| @echo off |
| setlocal enabledelayedexpansion |
| title E-Reader App Launcher |
|
|
| echo ================================================ |
| echo E-Reader App - Launcher |
| echo ================================================ |
| echo. |
|
|
| :: Set directories using absolute paths (avoiding issues with current dir) |
| set "BASE_DIR=%~dp0" |
| set "APP_DIR=%BASE_DIR%App" |
| set "BACKEND_DIR=%APP_DIR%\backend" |
| set "FRONTEND_DIR=%APP_DIR%\frontend" |
|
|
| :: Resolve Python and Uvicorn |
| set "UVICORN_EXE=%BACKEND_DIR%\venv\Scripts\uvicorn.exe" |
| set "PIP_EXE=%BACKEND_DIR%\venv\Scripts\pip.exe" |
|
|
| :: 1. Sanity Checks |
| if not exist "%APP_DIR%" ( |
| echo [ERROR] App folder not found at: %APP_DIR% |
| pause |
| exit /b 1 |
| ) |
|
|
| :: 2. Check/Install Backend |
| if not exist "%UVICORN_EXE%" ( |
| echo [INFO] Backend venv not found. Attempting to create it... |
| cd /d "%BACKEND_DIR%" |
| python -m venv venv |
| if !errorlevel! neq 0 ( |
| echo [ERROR] Failed to create venv. Please install Python and ensure it's in your PATH. |
| pause |
| exit /b 1 |
| ) |
| echo [INFO] Installing backend dependencies... |
| "%PIP_EXE%" install -r requirements.txt |
| ) |
|
|
| :: 3. Check/Install Frontend |
| if not exist "%FRONTEND_DIR%\node_modules" ( |
| echo [INFO] node_modules not found. Installing frontend dependencies... |
| cd /d "%FRONTEND_DIR%" |
| call npm install |
| if !errorlevel! neq 0 ( |
| echo [ERROR] Failed to install frontend dependencies. Please install Node.js/npm. |
| pause |
| exit /b 1 |
| ) |
| ) |
|
|
| echo. |
| echo [1/2] Starting Backend (Port 8000)... |
| start "Backend (FastAPI)" /D "%BACKEND_DIR%" cmd /k ""%UVICORN_EXE%" main:app --host 127.0.0.1 --port 8000" |
|
|
| timeout /t 2 /nobreak >nul |
|
|
| echo [2/2] Starting Frontend (Dev mode)... |
| :: Using /D to set the starting directory correctly |
| start "Frontend (Vite)" /D "%FRONTEND_DIR%" cmd /k "npm run dev" |
|
|
| echo. |
| echo Waiting for servers to spin up... |
| timeout /t 5 /nobreak >nul |
|
|
| echo. |
| echo ================================================ |
| echo Ready! Visit: http://localhost:5173 |
| echo ================================================ |
| echo. |
| pause |
|
|