path resolution
This commit is contained in:
+22
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user