34 lines
957 B
Python
34 lines
957 B
Python
from fastapi import APIRouter, Request
|
|
from fastapi.responses import JSONResponse
|
|
import logging
|
|
|
|
|
|
class HealthRoutes:
|
|
|
|
def __init__(self):
|
|
|
|
self.router = APIRouter()
|
|
|
|
self.router.add_api_route(
|
|
"/",
|
|
self.check_rest_health,
|
|
methods=["GET"],
|
|
tags=["Health"],
|
|
description="Health Check for the Rest service",
|
|
name="Health Check",
|
|
dependencies=[],
|
|
)
|
|
|
|
logging.info("health routes correctly initialized.")
|
|
|
|
async def check_rest_health(self, request: Request) -> JSONResponse:
|
|
|
|
try:
|
|
return JSONResponse(
|
|
content={"message": "WCAG Validator Inference Server is working! Now head over to http://localhost:xxx/docs"},
|
|
status_code=200,
|
|
)
|
|
except Exception as e:
|
|
logging.error(str(e))
|
|
return JSONResponse(content={"error": str(e)}, status_code=500)
|