fix: handle missing static directory gracefully for tests
Run Tests / Backend Tests (push) Failing after 1m30s
Run Tests / Test Summary (push) Has been cancelled
Run Tests / Frontend Tests (push) Has started running

This commit is contained in:
Gan, Jimmy
2026-04-04 13:31:32 +08:00
parent 0cfb1a6b5d
commit 3942a344c7
2 changed files with 14 additions and 14 deletions
+11 -1
View File
@@ -223,4 +223,14 @@ app.include_router(opc_projects.router, prefix="/api/opc",
app.add_api_websocket_route("/ws/terminal", terminal.ws_endpoint)
app.add_api_websocket_route("/ws/opc", opc_ws.websocket_endpoint)
app.mount("/", StaticFiles(directory="/app/static", html=True), name="static")
# Mount static files (skip if directory doesn't exist, e.g., in test environments)
import os
if os.path.isdir("/app/static"):
app.mount("/", StaticFiles(directory="/app/static", html=True), name="static")
else:
# In test environment, create a minimal fallback
import tempfile
_test_static = tempfile.mkdtemp()
with open(os.path.join(_test_static, "index.html"), "w") as f:
f.write("<html><body>Test Environment</body></html>")
app.mount("/", StaticFiles(directory=_test_static, html=True), name="static")