pryscraper/routers/system.py
cryptorugmunch 2f1eec2f78
Some checks failed
CI / lint (pull_request) Successful in 33s
CI / typecheck (pull_request) Failing after 1m42s
CI / test (pull_request) Failing after 2m33s
CI / security (pull_request) Failing after 39s
CI / gitleaks (pull_request) Successful in 36s
CI / commitlint (pull_request) Failing after 10s
style: ruff format
2026-07-03 18:12:36 +02:00

45 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)