19 lines
578 B
Python
19 lines
578 B
Python
from fastapi import APIRouter
|
|
from fastapi.responses import HTMLResponse
|
|
|
|
from app.plugins import PLUGINS, Plugin
|
|
from app.render import render
|
|
|
|
router = APIRouter(prefix="/api/plugins", tags=["plugins"])
|
|
|
|
|
|
@router.get("")
|
|
async def plugins_index():
|
|
items: list[dict[str, Plugin | str]] = []
|
|
for p in PLUGINS:
|
|
try:
|
|
body = await p.skeleton()
|
|
except Exception as e: # noqa
|
|
body = f"<div class='alert'>plugin error: {e}</div>"
|
|
items.append({"p": p, "body": body})
|
|
return HTMLResponse(render("plugins.html", items=items))
|