Restore basic health check to fix Render deploy

This commit is contained in:
2026-02-25 12:06:01 -05:00
parent 8f021c55b0
commit ad9bafe63d

View File

@ -121,22 +121,12 @@ origins = [
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Abrir temporalmente para diagnóstico
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@app.exception_handler(Exception)
async def global_exception_handler(request, exc):
# Loguear de forma segura sin caracteres especiales que rompan el terminal
logger.error(f"Global error on {request.url.path}: {str(exc)}")
return {"detail": "Internal Server Error", "message": "Verify database connection or payload"}
# Ensure upload directories exist
for sub in ["profiles", "vehicles", "businesses"]:
os.makedirs(os.path.join("uploads", sub), exist_ok=True)
@ -167,17 +157,6 @@ async def root():
@app.get("/health")
async def health(session: Session = Depends(get_session)):
"""Health check endpoint connecting to DB."""
db_status = "connected"
try:
from sqlalchemy import text
session.execute(text("SELECT 1"))
except Exception as e:
db_status = f"disconnected: {str(e)}"
return {
"status": "healthy" if db_status == "connected" else "degraded",
"environment": settings.environment,
"database": db_status
}
async def health():
"""Health check endpoint."""
return {"status": "healthy", "environment": settings.environment}