KarthikMuraliM commited on
Commit
af10285
·
verified ·
1 Parent(s): c0144f2

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -3
main.py CHANGED
@@ -79,9 +79,12 @@ async def process_analysis_request(request: Request):
79
 
80
  with tempfile.TemporaryDirectory() as work_dir:
81
  work_path = Path(work_dir)
82
- if not files: raise HTTPException(status.HTTP_400_BAD_REQUEST, "No files uploaded.")
83
-
84
- file_contents = {f.filename: await f.read() for f in files}
 
 
 
85
 
86
  # --- Two-Pass Logic to Reliably Find the Question File ---
87
  all_filenames = list(file_contents.keys())
 
79
 
80
  with tempfile.TemporaryDirectory() as work_dir:
81
  work_path = Path(work_dir)
82
+ form_data = await request.form()
83
+ all_files: List[UploadFile] = [part for part in form_data.values() if isinstance(part, UploadFile) and part.filename]
84
+ if not all_files: raise HTTPException(status.HTTP_400_BAD_REQUEST, "No files were uploaded.")
85
+
86
+ # This line now uses the correct variable name 'all_files'
87
+ file_contents = {f.filename: await f.read() for f in all_files}
88
 
89
  # --- Two-Pass Logic to Reliably Find the Question File ---
90
  all_filenames = list(file_contents.keys())