Spaces:
Sleeping
Sleeping
pierrelissope
commited on
Commit
·
6d73052
1
Parent(s):
b4dd83e
fix: fixed routes issues
Browse files
main.py
CHANGED
@@ -1,26 +1,23 @@
|
|
1 |
|
2 |
# Line for test push
|
3 |
|
4 |
-
from fastapi import FastAPI
|
5 |
from fastapi.staticfiles import StaticFiles
|
6 |
from starlette.responses import FileResponse
|
7 |
from transformers import pipeline
|
8 |
|
9 |
app = FastAPI()
|
10 |
-
|
11 |
-
# Initialiser le pipeline pour Flan T5
|
12 |
-
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
|
13 |
-
|
14 |
-
# Route d'inférence
|
15 |
-
@app.get("/infer_t5")
|
16 |
-
async def infer_t5(input: str):
|
17 |
-
output = pipe_flan(input)
|
18 |
-
return {"output": output[0]["generated_text"]}
|
19 |
|
20 |
# Monter les fichiers statiques
|
21 |
-
app.mount("/", StaticFiles(directory="front/dist", html=True), name="static")
|
22 |
|
23 |
-
@
|
24 |
async def index() -> FileResponse:
|
25 |
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
|
|
|
|
|
|
|
|
|
|
26 |
|
|
|
|
1 |
|
2 |
# Line for test push
|
3 |
|
4 |
+
from fastapi import FastAPI, APIRouter
|
5 |
from fastapi.staticfiles import StaticFiles
|
6 |
from starlette.responses import FileResponse
|
7 |
from transformers import pipeline
|
8 |
|
9 |
app = FastAPI()
|
10 |
+
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Monter les fichiers statiques
|
|
|
13 |
|
14 |
+
@router.get("/")
|
15 |
async def index() -> FileResponse:
|
16 |
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
17 |
+
@router.get("/verification")
|
18 |
+
async def verif() -> FileResponse:
|
19 |
+
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
20 |
+
|
21 |
+
app.include_router(router)
|
22 |
|
23 |
+
app.mount("/", StaticFiles(directory="front/dist", html=True), name="static")
|