Spaces:
Sleeping
Sleeping
pierrelissope
commited on
Commit
·
f15562f
1
Parent(s):
928495f
fix: fixed route
Browse files
main.py
CHANGED
@@ -2,6 +2,9 @@ from fastapi import FastAPI, APIRouter
|
|
2 |
from fastapi.staticfiles import StaticFiles
|
3 |
from starlette.responses import FileResponse
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
|
|
5 |
|
6 |
app = FastAPI()
|
7 |
router = APIRouter()
|
@@ -14,6 +17,13 @@ app.add_middleware(
|
|
14 |
allow_headers=["*"],
|
15 |
)
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
@router.get("/")
|
18 |
async def index() -> FileResponse:
|
19 |
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
@@ -22,11 +32,16 @@ async def verif() -> FileResponse:
|
|
22 |
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
23 |
|
24 |
@router.post("/uploadpdf")
|
25 |
-
async def upload_pdf():
|
|
|
|
|
|
|
|
|
|
|
26 |
return {"message": "Image reçue et sauvegardée"}
|
27 |
|
28 |
@router.post("/uploadids")
|
29 |
-
async def upload_ids():
|
30 |
return {"message": "Images reçues et sauvegardées"}
|
31 |
|
32 |
|
|
|
2 |
from fastapi.staticfiles import StaticFiles
|
3 |
from starlette.responses import FileResponse
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
+
import base64
|
6 |
+
from pydantic import BaseModel
|
7 |
+
import time
|
8 |
|
9 |
app = FastAPI()
|
10 |
router = APIRouter()
|
|
|
17 |
allow_headers=["*"],
|
18 |
)
|
19 |
|
20 |
+
class ImageData(BaseModel):
|
21 |
+
image: str
|
22 |
+
|
23 |
+
class ImagesData(BaseModel):
|
24 |
+
idCard: str
|
25 |
+
profileImage: str
|
26 |
+
|
27 |
@router.get("/")
|
28 |
async def index() -> FileResponse:
|
29 |
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
|
|
32 |
return FileResponse(path="front/dist/index.html", media_type="text/html")
|
33 |
|
34 |
@router.post("/uploadpdf")
|
35 |
+
async def upload_pdf(data: ImageData):
|
36 |
+
header, encoded = data.image.split(',', 1)
|
37 |
+
binary_data = base64.b64decode(encoded)
|
38 |
+
|
39 |
+
time.sleep(20)
|
40 |
+
|
41 |
return {"message": "Image reçue et sauvegardée"}
|
42 |
|
43 |
@router.post("/uploadids")
|
44 |
+
async def upload_ids(data: ImagesData):
|
45 |
return {"message": "Images reçues et sauvegardées"}
|
46 |
|
47 |
|