Skip to content

Commit 694cf0a

Browse files
rlafurudclaude
andcommitted
feat(local): single-process run — backend serves built UI + start_local.bat
- app.py mounts frontend/dist (if present) so 'python -m uvicorn app:app' serves the UI + API + the real BAR launch from one process (no Node at runtime). Skipped on the cloud backend where dist isn't deployed. - start_local.bat: one-click local launch (opens http://localhost:8000). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6cdf0f0 commit 694cf0a

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

backend/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from fastapi import FastAPI
2727
from fastapi.middleware.cors import CORSMiddleware
28+
from fastapi.staticfiles import StaticFiles
2829
from pydantic import BaseModel
2930

3031
import pipeline
@@ -172,6 +173,16 @@ def launch(req: LaunchRequest):
172173
}
173174

174175

176+
# Serve the built frontend if present, so `start_local` can run the whole app
177+
# (UI + API + BAR launch) as a single Python process — no Node needed at run
178+
# time. On the cloud backend dist isn't deployed, so this is skipped and the API
179+
# runs alone (the frontend is hosted separately on Vercel). Mounted LAST so the
180+
# API routes above always take precedence.
181+
_DIST = CURRENT_DIR.parent / "frontend" / "dist"
182+
if _DIST.is_dir():
183+
app.mount("/", StaticFiles(directory=str(_DIST), html=True), name="spa")
184+
185+
175186
if __name__ == "__main__":
176187
import uvicorn
177188
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True)

start_local.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@echo off
2+
REM ============================================================
3+
REM RTSGame - one-click LOCAL run (Windows)
4+
REM Backend serves the API + the built UI + the real "BAR에서 실행".
5+
REM Requires: Python on PATH, backend\.env with OPENAI_API_KEY,
6+
REM frontend\dist built (npm run build), and BAR installed.
7+
REM Open http://localhost:8000 when it starts.
8+
REM ============================================================
9+
cd /d "%~dp0backend"
10+
11+
if not exist "..\frontend\dist\index.html" (
12+
echo [!] frontend\dist not found. Build it once with: cd frontend ^&^& npm run build
13+
echo ^(API will still run, but the UI page will be missing.^)
14+
)
15+
16+
REM open the browser a few seconds after the server starts
17+
start "" cmd /c "timeout /t 4 >nul & start http://localhost:8000"
18+
19+
echo Starting RTSGame on http://localhost:8000 (close this window to stop)
20+
python -m uvicorn app:app --host 127.0.0.1 --port 8000

0 commit comments

Comments
 (0)