Spaces:
Sleeping
Sleeping
import herramientas | |
from io import BytesIO | |
import funciones, globales | |
from fastapi import FastAPI, Form | |
from fastapi import FastAPI, File, UploadFile | |
from fastapi.responses import StreamingResponse, FileResponse, JSONResponse | |
app = FastAPI() | |
# Nuevo endpoint para 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) | |
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) |