Spaces:
Sleeping
Sleeping
Download app/api/debug_admin.py from yabeskn/briga-core-api: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/yabeskn/briga-core-api/resolve/main/app/api/debug_admin.py
- Command line
-
hf download hf://spaces/yabeskn/briga-core-api/app/api/debug_admin.py
-
curl -L -o debug_admin.py https://huggingface.co/spaces/yabeskn/briga-core-api/resolve/main/app/api/debug_admin.py
1.03 kB
| from fastapi import APIRouter, Depends, Request, HTTPException | |
| from sqlalchemy.ext.asyncio import AsyncSession | |
| from sqlalchemy import select | |
| from app.database import get_db | |
| from app.models.system import WorkflowConfig | |
| router = APIRouter(prefix="/v1/debug", tags=["Debug"]) | |
| async def debug_list_workflows(request: Request, db: AsyncSession = Depends(get_db)): | |
| """Debug endpoint: admin-only workflow listing.""" | |
| role = getattr(request.state, "user_role", None) | |
| if role not in ("admin", "ADMIN"): | |
| raise HTTPException(status_code=403, detail="Admin role required") | |
| result = await db.execute(select(WorkflowConfig)) | |
| rows = result.scalars().all() | |
| return {"success": True, "workflows": [ | |
| { | |
| "workflow_name": r.workflow_name, | |
| "is_active": r.is_active, | |
| "schedule_cron": r.schedule_cron, | |
| "last_run": r.last_run, | |
| "updated_at": r.updated_at, | |
| } | |
| for r in rows | |
| ]} | |