Spaces:
Running
Running
add
Browse files
app.py
CHANGED
|
@@ -73,6 +73,7 @@ from transformers import pipeline
|
|
| 73 |
from PIL import Image
|
| 74 |
import io
|
| 75 |
import docx2txt
|
|
|
|
| 76 |
|
| 77 |
|
| 78 |
# Configuration du logging
|
|
@@ -193,6 +194,10 @@ print("hello")
|
|
| 193 |
async def generate_viz(file: UploadFile = File(...), query: str = Form(...)):
|
| 194 |
print("hello")
|
| 195 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
if query not in VALID_PLOTS:
|
| 197 |
return JSONResponse(content={"error": f"Type de graphique invalide. Choisissez parmi : {', '.join(VALID_PLOTS)}"}, status_code=400)
|
| 198 |
|
|
|
|
| 73 |
from PIL import Image
|
| 74 |
import io
|
| 75 |
import docx2txt
|
| 76 |
+
from fastapi.responses import StreamingResponse
|
| 77 |
|
| 78 |
|
| 79 |
# Configuration du logging
|
|
|
|
| 194 |
async def generate_viz(file: UploadFile = File(...), query: str = Form(...)):
|
| 195 |
print("hello")
|
| 196 |
try:
|
| 197 |
+
contents = await file.read() # 👈 Lire tout le contenu du fichier
|
| 198 |
+
excel_file = io.BytesIO(contents) # 👈 Le convertir en fichier binaire en mémoire
|
| 199 |
+
df = pd.read_excel(excel_file) # 👈 Pandas lit depuis le BytesIO
|
| 200 |
+
|
| 201 |
if query not in VALID_PLOTS:
|
| 202 |
return JSONResponse(content={"error": f"Type de graphique invalide. Choisissez parmi : {', '.join(VALID_PLOTS)}"}, status_code=400)
|
| 203 |
|