File size: 1,566 Bytes
435164a 95da284 d90d6a6 5b38336 bddc6a2 5b38336 bddc6a2 435164a bddc6a2 95da284 435164a 95da284 5b38336 8972247 435164a 8972247 435164a |
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 |
import ia
from io import BytesIO
from fastapi import FastAPI, Form
from fastapi import FastAPI, File, UploadFile
from fastapi.responses import StreamingResponse, FileResponse, JSONResponse
app = FastAPI()
@app.get("/health",
tags=["Monitoreo Server"],
description="Verifica el estado de salud de la API.",
summary="Health Check"
)
async def health_check():
"""
Este endpoint devuelve una respuesta 200 OK para indicar que la API está funcionando.
"""
return JSONResponse(content={"status": "ok"}, status_code=200)
@app.post("/echo-image/",
tags=["Monitoreo Server"],
description="Test endpoint para prueba de envío de imagenes.",
summary="Mirror test para envío de imagenes"
)
async def echo_image(image: UploadFile = File(...)):
if not image.content_type.startswith("image/"):
return {"error": "El archivo no es una imagen"}
contents = await image.read()
return StreamingResponse(BytesIO(contents), media_type=image.content_type)
@app.post("/procesa-dni/",
tags=["Rapicash"],
description="Procesa DNI de Panamá obteniendo los datos deseados.",
summary="Identificación de DNI con IA"
)
async def echo_image(image: UploadFile = File(...)):
if not image.content_type.startswith("image/"):
return {"error": "El archivo no es una imagen"}
contents = await image.read()
# return StreamingResponse(BytesIO(contents), media_type=image.content_type)
return ia.inference(contents, 'en') |