Spaces:
Runtime error
Runtime error
| 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() | |
| 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) | |
| 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) | |
| 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') |