Spaces:
Sleeping
Sleeping
ππ»
Browse files
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 |
-
|
| 84 |
-
|
|
|
|
|
|
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
| 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())
|