Some checks failed
- AST-extract all remaining routes from api.py into routers/*.py - Group routes by OpenAPI tag (AI, Advanced, Agency, ..., x402) - Keep existing auth/health/scraping/templates routers; add *_api.py for remaining routes of those tags - Move shared helpers/models/variables with the routes that need them - Update tests/test_api.py to import vision helpers from routers.vision - Regenerate openapi.json (186 paths) - All 497 tests pass; ruff clean
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""Pry — System 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 fastapi import APIRouter, Response
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from observability import get_metrics_output
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
router = APIRouter(tags=["System"])
|
|
|
|
@router.get("/metrics", tags=["System"], summary="Prometheus metrics", include_in_schema=False)
|
|
async def metrics() -> Response:
|
|
"""Expose Prometheus metrics for scraping."""
|
|
data, content_type = get_metrics_output()
|
|
return Response(content=data, media_type=content_type)
|
|
|
|
|
|
@router.get(
|
|
"/openapi.json",
|
|
tags=["System"],
|
|
summary="OpenAPI spec for AI agent integration",
|
|
include_in_schema=False,
|
|
)
|
|
async def get_openapi() -> JSONResponse:
|
|
"""Get the OpenAPI specification for AI agent integration.
|
|
|
|
Use this with ChatGPT GPT Actions, Claude MCP, or any AI agent
|
|
framework to let AI models scrape the web through Pry.
|
|
"""
|
|
from ai_plugin import get_openapi_spec
|
|
|
|
spec = get_openapi_spec()
|
|
return JSONResponse(content=spec)
|