Files
foodlinkk-command-center/cockpit/app/routes/reco_proxy.py
T
Aissa 5d60d33db1 Platform bundle: marketing publish, IT ops, packaging, agents mesh.
Volledige Foodlinkk Command Center uitbreiding met social automatisering,
reclamefolder filters, Proxmox monitoring en documentatie.
2026-06-09 00:41:27 +00:00

40 lines
1.2 KiB
Python

"""Proxy recommendations to Tools API."""
from __future__ import annotations
import os
import httpx
from fastapi import APIRouter
admin_router = None # patched into admin_api
TOOLS = os.getenv("TOOLS_API_URL", "http://tools-api:8700").rstrip("/")
async def _proxy(method: str, path: str):
async with httpx.AsyncClient(timeout=60) as client:
r = await getattr(client, method.lower())(f"{TOOLS}{path}")
return r.json()
def register_recommendation_routes(router: APIRouter) -> None:
@router.get("/recommendations/pending")
async def reco_pending():
return await _proxy("GET", "/recommendations/pending")
@router.post("/recommendations/generate")
async def reco_generate():
return await _proxy("POST", "/recommendations/generate")
@router.post("/recommendations/{rec_id}/approve")
async def reco_approve(rec_id: int):
return await _proxy("POST", f"/recommendations/{rec_id}/approve")
@router.post("/recommendations/{rec_id}/dismiss")
async def reco_dismiss(rec_id: int):
return await _proxy("POST", f"/recommendations/{rec_id}/dismiss")
@router.post("/research/run")
async def research_run():
return await _proxy("POST", "/research/run")