openoperator / patches /api /api_docs.py
Leon4gr45's picture
Redeploy with build fixes and framework integrity
21927d0 verified
raw
history blame contribute delete
896 Bytes
import os
import threading
from typing import Any
from flask import Flask
class ApiDocs:
def __init__(self, webapp: Flask, lock: threading.Lock) -> None:
self.webapp = webapp
self.lock = lock
async def process(self, data: dict[str, Any], request: Any) -> dict[str, Any]:
endpoints = []
for rule in self.webapp.url_map.iter_rules():
if rule.rule.startswith("/api/"):
methods = ",".join(m for m in rule.methods if m not in ["OPTIONS", "HEAD"])
endpoints.append({
"path": rule.rule,
"methods": methods,
"endpoint": rule.endpoint
})
return {
"title": "Agent-Zero API Documentation",
"version": "1.0.0",
"hf_space": os.getenv("HF_SPACE") == "true",
"endpoints": endpoints
}