Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
@@ -12,7 +12,9 @@ import pandas as pd
|
|
12 |
import pptx
|
13 |
from fastapi.middleware.cors import CORSMiddleware
|
14 |
from langdetect import detect
|
15 |
-
|
|
|
|
|
16 |
app = FastAPI()
|
17 |
|
18 |
app.add_middleware(
|
@@ -139,7 +141,19 @@ def translate_text(text, source_lang, target_lang):
|
|
139 |
|
140 |
return None # Pas de modèle disponible
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
@app.post("/translate")
|
|
|
143 |
async def translate_document(file: UploadFile = File(...), language: str = Form(...)):
|
144 |
try:
|
145 |
suffix = file.filename.split(".")[-1].lower()
|
|
|
12 |
import pptx
|
13 |
from fastapi.middleware.cors import CORSMiddleware
|
14 |
from langdetect import detect
|
15 |
+
from fastapi.staticfiles import StaticFiles
|
16 |
+
from fastapi.responses import HTMLResponse
|
17 |
+
from fastapi import Request
|
18 |
app = FastAPI()
|
19 |
|
20 |
app.add_middleware(
|
|
|
141 |
|
142 |
return None # Pas de modèle disponible
|
143 |
|
144 |
+
|
145 |
+
# Monter les fichiers statiques
|
146 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
147 |
+
app.mount("/assete", StaticFiles(directory="assete"), name="assete")
|
148 |
+
|
149 |
+
# Route pour accéder à la page principale (index.html)
|
150 |
+
@app.get("/", response_class=HTMLResponse)
|
151 |
+
async def serve_frontend():
|
152 |
+
with open("static/prj.html", "r", encoding="utf-8") as f:
|
153 |
+
return f.read()
|
154 |
+
|
155 |
@app.post("/translate")
|
156 |
+
|
157 |
async def translate_document(file: UploadFile = File(...), language: str = Form(...)):
|
158 |
try:
|
159 |
suffix = file.filename.split(".")[-1].lower()
|