28 lines
725 B
Python
28 lines
725 B
Python
import tomllib
|
|
from pathlib import Path
|
|
from fastapi import APIRouter
|
|
|
|
# Создаем базовый router для FastAPI
|
|
router = APIRouter(tags=["base"])
|
|
|
|
def get_version():
|
|
"""Получить версию из pyproject.toml"""
|
|
try:
|
|
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
|
|
with open(pyproject_path, "rb") as f:
|
|
pyproject = tomllib.load(f)
|
|
return pyproject["project"]["version"]
|
|
except:
|
|
return "0.1.0"
|
|
|
|
@router.get("/")
|
|
async def root():
|
|
return {"message": "API is running"}
|
|
|
|
@router.get("/health")
|
|
async def health():
|
|
return {"status": "ok"}
|
|
|
|
@router.get("/version")
|
|
async def version():
|
|
return {"version": get_version()} |