feat: Work with png and jpg

This commit is contained in:
Mario Gil 2024-09-10 15:52:30 -05:00
parent 4ac7e2ec53
commit 7620fd6679
1 changed files with 9 additions and 2 deletions

View File

@ -97,9 +97,16 @@ menuLLM=""" <option value="meta-llama/Meta-Llama-3.1-70B-Instruct">meta-l
@app.post("/uploadimg") @app.post("/uploadimg")
def upload_image(image: UploadFile = File(...),type="factura"): def upload_image(image: UploadFile = File(...),type="factura"):
if image.headers['content-type']=='image/png':
endfile=".png"
elif image.headers['content-type']=='image/jpeg':
endfile=".jpg" endfile=".jpg"
else:
return JSONResponse(content={
"message": f"The file should be png or jpg"
}, status_code=500)
t=time.time() t=time.time()
print(image.headers)
try: try:
# Create a temporary file to store the uploaded audio # Create a temporary file to store the uploaded audio
headfilename=uuid.uuid4() headfilename=uuid.uuid4()