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

πŸ™πŸ»

Browse files
Files changed (1) hide show
  1. main.py +9 -4
main.py CHANGED
@@ -80,11 +80,16 @@ async def process_analysis_request(request: Request):
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())
 
80
  with tempfile.TemporaryDirectory() as work_dir:
81
  work_path = Path(work_dir)
82
  form_data = await request.form()
83
+ all_uploaded_files = []
84
+ for key, value in form_data.items():
85
+ if isinstance(value, UploadFile):
86
+ all_uploaded_files.append(value)
87
 
88
+ if not all_uploaded_files:
89
+ raise HTTPException(status.HTTP_400_BAD_REQUEST, "No files were uploaded.")
90
+
91
+ # Read all discovered files into memory ONCE
92
+ file_contents = {f.filename: await f.read() for f in all_uploaded_files}
93
 
94
  # --- Two-Pass Logic to Reliably Find the Question File ---
95
  all_filenames = list(file_contents.keys())