claudqunwang Cursor commited on
Commit
0bfc239
·
1 Parent(s): 56c2a52

debug: 添加静态文件路径调试日志,排查空白页面问题

Browse files

Co-authored-by: Cursor <cursoragent@cursor.com>

Files changed (1) hide show
  1. api/server.py +15 -0
api/server.py CHANGED
@@ -103,17 +103,32 @@ app.include_router(courseware_router)
103
  # ----------------------------
104
  # Static hosting (Vite build)
105
  # ----------------------------
 
 
 
 
 
 
 
106
  if os.path.isdir(WEB_ASSETS):
 
107
  app.mount("/assets", StaticFiles(directory=WEB_ASSETS), name="assets")
 
 
108
 
109
  if os.path.isdir(WEB_DIST):
 
110
  app.mount("/static", StaticFiles(directory=WEB_DIST), name="static")
 
 
111
 
112
 
113
  @app.get("/")
114
  def index():
115
  if os.path.exists(WEB_INDEX):
 
116
  return FileResponse(WEB_INDEX)
 
117
  return JSONResponse(
118
  {"detail": "web/build not found. Build frontend first (web/build/index.html)."},
119
  status_code=500,
 
103
  # ----------------------------
104
  # Static hosting (Vite build)
105
  # ----------------------------
106
+ print(f"[DEBUG] WEB_DIST: {WEB_DIST}")
107
+ print(f"[DEBUG] WEB_INDEX: {WEB_INDEX}")
108
+ print(f"[DEBUG] WEB_ASSETS: {WEB_ASSETS}")
109
+ print(f"[DEBUG] WEB_INDEX exists: {os.path.exists(WEB_INDEX)}")
110
+ print(f"[DEBUG] WEB_ASSETS exists: {os.path.isdir(WEB_ASSETS)}")
111
+ print(f"[DEBUG] WEB_DIST exists: {os.path.isdir(WEB_DIST)}")
112
+
113
  if os.path.isdir(WEB_ASSETS):
114
+ print(f"[DEBUG] Mounting /assets from {WEB_ASSETS}")
115
  app.mount("/assets", StaticFiles(directory=WEB_ASSETS), name="assets")
116
+ else:
117
+ print(f"[WARNING] WEB_ASSETS directory not found: {WEB_ASSETS}")
118
 
119
  if os.path.isdir(WEB_DIST):
120
+ print(f"[DEBUG] Mounting /static from {WEB_DIST}")
121
  app.mount("/static", StaticFiles(directory=WEB_DIST), name="static")
122
+ else:
123
+ print(f"[WARNING] WEB_DIST directory not found: {WEB_DIST}")
124
 
125
 
126
  @app.get("/")
127
  def index():
128
  if os.path.exists(WEB_INDEX):
129
+ print(f"[DEBUG] Serving index.html from {WEB_INDEX}")
130
  return FileResponse(WEB_INDEX)
131
+ print(f"[ERROR] WEB_INDEX not found: {WEB_INDEX}")
132
  return JSONResponse(
133
  {"detail": "web/build not found. Build frontend first (web/build/index.html)."},
134
  status_code=500,