fix([2fd88f42]): implement vite proxy for robust API calls and add logging

This commit is contained in:
2026-02-04 12:13:45 +00:00
parent 20dd56b5cf
commit 5d3caf6258
4 changed files with 18 additions and 2 deletions

View File

@@ -44,6 +44,7 @@ def read_root():
@app.post("/api/upload")
async def upload_file(file: UploadFile = File(...)):
global df_storage, plz_column_name
print(f"--- Received request to /api/upload for file: {file.filename} ---")
if not file.filename.endswith('.xlsx'):
raise HTTPException(status_code=400, detail="Invalid file format. Please upload an .xlsx file.")
@@ -77,16 +78,20 @@ async def upload_file(file: UploadFile = File(...)):
df_storage = df
print(f"Successfully processed file. Found PLZ column: '{plz_column_name}'. Detected {len(filters)} filterable columns.")
return {"filename": file.filename, "filters": filters, "plz_column": plz_column_name}
except Exception as e:
print(f"ERROR processing file: {e}")
raise HTTPException(status_code=500, detail=f"An error occurred while processing the file: {e}")
@app.post("/api/heatmap")
async def get_heatmap_data(request: FilterRequest):
global df_storage, plz_column_name
print(f"--- Received request to /api/heatmap with filters: {request.filters} ---")
if df_storage is None:
print("ERROR: No data in df_storage. File must be uploaded first.")
raise HTTPException(status_code=404, detail="No data available. Please upload a file first.")
try:
@@ -117,7 +122,9 @@ async def get_heatmap_data(request: FilterRequest):
"count": row["count"]
})
print(f"Generated heatmap data with {len(heatmap_data)} PLZ points.")
return heatmap_data
except Exception as e:
print(f"ERROR generating heatmap: {e}")
raise HTTPException(status_code=500, detail=f"An error occurred while generating heatmap data: {e}")