fix: handle missing static directory gracefully for tests
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user