INNER CODE UNIT · Python

api_stats

Nuclear-Marmalade/dataforge · forge/dashboard/app.py:341

async def api_stats():
    """Return database stats as JSON (polled by HTMX on dashboard)."""
    db = _get_db()
    if not db:
        return JSONResponse({"error": "Database not available", "total_records": 0})
    stats = db.get_stats()
    return JSONResponse(stats)


def _validate_discover_input(zip_code: str) -> Optional[HTMLResponse]:
    """Return an error HTMLResponse if zip_code is invalid, else None."""
    if not zip_code or len(zip_code) != 5:
        return HTMLResponse(
            '<div class="forge-card text-red-400 text-center py-4">'
            "Please enter a valid 5-digit ZIP code</div>"
        )
    return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…