pryscraper/routers/system.py
cryptorugmunch 9fee12796e
Some checks failed
CI / Security audit (bandit) (pull_request) Successful in 36s
CI / test (pull_request) Successful in 1m19s
CI / lint (pull_request) Failing after 49s
CI / typecheck (pull_request) Successful in 54s
CI / Secret scan (gitleaks) (pull_request) Successful in 34s
feat(routers): split remaining 174 api.py routes into per-tag routers
- 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
2026-07-03 03:42:36 +02:00

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)