Spaces:
Running
Running
| from __future__ import annotations | |
| import importlib.util | |
| import shutil | |
| import time | |
| from fastapi import APIRouter, Request | |
| from app.core.response import SuccessResponse | |
| router = APIRouter(tags=["health"]) | |
| async def _health(request: Request) -> SuccessResponse: | |
| started = time.monotonic() | |
| settings = request.app.state.container.settings | |
| dependencies = { | |
| "ffmpeg": shutil.which(settings.ffmpeg_binary) is not None, | |
| "ffprobe": shutil.which(settings.ffprobe_binary) is not None, | |
| "yt_dlp": importlib.util.find_spec("yt_dlp") is not None, | |
| "faster_whisper": importlib.util.find_spec("faster_whisper") is not None, | |
| } | |
| return SuccessResponse( | |
| request_id=request.state.request_id, | |
| processing_time=round(time.monotonic() - started, 4), | |
| metadata={ | |
| "status": "healthy", | |
| "version": settings.app_version, | |
| "dependencies": dependencies, | |
| }, | |
| ) | |
| router.add_api_route("/health", _health, methods=["GET"], response_model=SuccessResponse) | |
| router.add_api_route( | |
| "/v1/health", _health, methods=["GET"], response_model=SuccessResponse, include_in_schema=False | |
| ) | |