path resolution

This commit is contained in:
2026-07-13 11:24:07 -04:00
parent bdaf5034dd
commit d2e0e7bdcb
2 changed files with 22 additions and 9 deletions
+22 -4
View File
@@ -282,7 +282,12 @@ app = FastAPI(title="Scheduler API", version="0.1.0", lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173"],
allow_origins=[
"http://localhost:5173",
"http://127.0.0.1:5173",
"http://localhost:8080",
"http://127.0.0.1:8080",
],
allow_methods=["*"],
allow_headers=["*"],
)
@@ -307,9 +312,22 @@ def get_settings() -> dict[str, Any]:
@app.post("/api/tests/load")
def load_tests(request: LoadTestsRequest) -> dict[str, Any]:
csv_path = Path(request.csv_path)
if not csv_path.is_absolute():
csv_path = APP_ROOT / csv_path
received_path = request.csv_path
# Handle absolute paths (Windows or Unix) by extracting just the filename
if "\\" in received_path or ":" in received_path or received_path.startswith("/"):
# Absolute path (Windows with backslash or drive letter, or Unix with /)
# Extract just the filename from the path
filename = received_path.replace("\\", "/").split("/")[-1]
data_dir_path = APP_ROOT / "data" / filename
if data_dir_path.exists():
csv_path = data_dir_path
else:
csv_path = APP_ROOT / filename
else:
# Relative paths - prepend APP_ROOT
csv_path = APP_ROOT / received_path
settings = db.read_settings(DB_PATH)
smb_credentials = _smb_credentials_from_settings(settings)