mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 21:24:16 +08:00
40 lines
979 B
Python
40 lines
979 B
Python
"""API 路由 — Phase 0 仅 /health 与 /api/capabilities。"""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app import __version__
|
|
from app.config import settings
|
|
from app.tickflow.policy import detect_capabilities, tier_label
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health")
|
|
def health() -> dict:
|
|
return {
|
|
"status": "ok",
|
|
"version": __version__,
|
|
"mode": "free" if settings.use_free_mode else "api_key",
|
|
}
|
|
|
|
|
|
@router.get("/api/capabilities")
|
|
def capabilities() -> dict:
|
|
"""前端用来决定哪些功能可用、哪些灰显。"""
|
|
capset = detect_capabilities()
|
|
return {
|
|
"label": tier_label(),
|
|
"capabilities": capset.to_dict(),
|
|
}
|
|
|
|
|
|
@router.post("/api/capabilities/redetect")
|
|
def redetect() -> dict:
|
|
"""用户在设置页"重新检测"按钮。"""
|
|
capset = detect_capabilities(force=True)
|
|
return {
|
|
"label": tier_label(),
|
|
"capabilities": capset.to_dict(),
|
|
}
|