Spaces:
Sleeping
Sleeping
File size: 1,119 Bytes
c3a38ec 7892632 c3a38ec 7892632 c3a38ec 7892632 c3a38ec 7892632 c3a38ec 7892632 c3a38ec 7892632 c3a38ec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
import time
from pydantic import BaseModel
import base64
from fastapi import FastAPI, APIRouter
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
origins = [
"http://localhost:7860",
"https://example.com",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
class ImageData(BaseModel):
image: str
class ImagesData(BaseModel):
idCard: str
profileImage: str
@app.post("/uploadpdf")
async def upload_pdf(image_data: ImageData):
header, encoded = image_data.image.split(',', 1)
binary_data = base64.b64decode(encoded)
time.sleep(20);
return {"message": "Image reçue et sauvegardée"}
@app.post("/uploadids")
async def upload_ids(images_data: ImagesData):
header, encoded = images_data.idCard.split(',', 1)
id_card_binary_data = base64.b64decode(encoded)
header, encoded = images_data.idCard.split(',', 1)
profile_image_binary_data = base64.b64decode(encoded)
time.sleep(20);
return {"message": "Image reçue et sauvegardée"}
|