Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import re
|
| 2 |
-
from fastapi import FastAPI, UploadFile, File, HTTPException, status
|
| 3 |
from typing import List,Dict
|
| 4 |
from pathlib import Path
|
| 5 |
import os
|
|
@@ -84,10 +84,8 @@ async def process_analysis_request(files: List[UploadFile] = File(...)):
|
|
| 84 |
# Manually parse the form data from the raw request. This is the key change.
|
| 85 |
form_data = await request.form()
|
| 86 |
all_files: List[UploadFile] = [part for part in form_data.values() if isinstance(part, UploadFile) and part.filename]
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
# Read all files into memory to avoid stream issues
|
| 91 |
file_contents = {f.filename: await f.read() for f in all_files}
|
| 92 |
|
| 93 |
# --- Now, perform the proven logic on the filenames ---
|
|
|
|
| 1 |
import re
|
| 2 |
+
from fastapi import FastAPI, UploadFile, File, HTTPException, status,Request
|
| 3 |
from typing import List,Dict
|
| 4 |
from pathlib import Path
|
| 5 |
import os
|
|
|
|
| 84 |
# Manually parse the form data from the raw request. This is the key change.
|
| 85 |
form_data = await request.form()
|
| 86 |
all_files: List[UploadFile] = [part for part in form_data.values() if isinstance(part, UploadFile) and part.filename]
|
| 87 |
+
|
| 88 |
+
# This block correctly reads all files into memory ONCE, fixing the FileNotFoundError
|
|
|
|
|
|
|
| 89 |
file_contents = {f.filename: await f.read() for f in all_files}
|
| 90 |
|
| 91 |
# --- Now, perform the proven logic on the filenames ---
|