"""Pry — Dashboard router (remaining api.py routes). Auto-extracted from api.py during the router-split refactor. """ # SPDX-License-Identifier: MIT # Copyright (c) 2026 Rug Munch Media LLC from __future__ import annotations import logging from datetime import UTC, datetime from fastapi import APIRouter from fastapi.responses import HTMLResponse from deps import automator, cache, ratelimiter logger = logging.getLogger(__name__) router = APIRouter(tags=["Dashboard"]) @router.get("/dashboard", tags=["Dashboard"], summary="Pry health and performance dashboard") async def dashboard() -> HTMLResponse: cache_stats = cache.stats() rate_stats = ratelimiter.get_stats() html = f""" Pry — Dashboard

🔧 Pry Dashboard

Scrape engine health and performance metrics

Cache Hit Rate

{cache_stats.get("hit_rate", 0)}%
{cache_stats.get("hits", 0)} hits / {cache_stats.get("size", 0)} entries

Rate Limit

{rate_stats.get("total_requests", 0)}
{rate_stats.get("active_ips", 0)} active IPs

Blocked

{rate_stats.get("total_blocked", 0)}
requests blocked

Sessions

{len(automator.sessions)}
active browser sessions
EndpointMethodStatus
/v1/scrapePOST✅ Active
/v1/crawlPOST✅ Active
/v1/automatePOST✅ Active
/v1/batchPOST✅ Active
/v1/streamWebSocket✅ Active
/v1/runPOST✅ Active
FlareSolverrProxy✅ Connected

Pry v3.0.0 — Generated {datetime.now(UTC).strftime("%Y-%m-%d %H:%M UTC")}

""" return HTMLResponse(content=html)