Bruno Charest c3cd7c2621
Some checks failed
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled
feat: Implement initial Homelab Automation API v2 with new models, routes, and core architecture, including a SQLAlchemy model refactoring script.
2026-03-03 20:18:22 -05:00

40 lines
1.1 KiB
Python

import sys
import time
from datetime import datetime, timezone
from fastapi import APIRouter, Depends
from app.core.config import settings
from app.core.dependencies import verify_api_key
router = APIRouter()
_START_TIME = time.monotonic()
@router.get("/config")
async def get_app_config():
"""Récupère la configuration publique de l'application."""
return {
"debug_mode": bool(settings.debug_mode),
}
@router.get("/config/version")
async def get_app_version(api_key_valid: bool = Depends(verify_api_key)):
"""Retourne la version de l'application, Python, et l'uptime."""
uptime_seconds = int(time.monotonic() - _START_TIME)
hours, remainder = divmod(uptime_seconds, 3600)
minutes, seconds = divmod(remainder, 60)
return {
"app_version": settings.api_version,
"app_title": settings.api_title,
"python_version": sys.version,
"python_executable": sys.executable,
"timezone": settings.scheduler_timezone,
"uptime": f"{hours}h {minutes}m {seconds}s",
"uptime_seconds": uptime_seconds,
"server_time": datetime.now(timezone.utc).isoformat(),
}