MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _handle_api

Method _handle_api

deployments/desktop/server.py:515–525  ·  view source on GitHub ↗
(self, routes: Dict[str, ApiHandler], body: Dict[str, Any] | None = None)

Source from the content-addressed store, hash-verified

513 self.wfile.write(data)
514
515 def _handle_api(self, routes: Dict[str, ApiHandler], body: Dict[str, Any] | None = None) -> None:
516 path, query_params = _query(self.path)
517 route = routes.get(path)
518 if route is None:
519 self._send_json({"ok": False, "error": f"Unknown API route: {path}"}, status=HTTPStatus.NOT_FOUND)
520 return
521 try:
522 payload = route(query_params, body or {})
523 self._send_json({"ok": True, **payload})
524 except Exception as exc:
525 self._send_json({"ok": False, "error": str(exc)}, status=HTTPStatus.BAD_REQUEST)
526
527 def _send_sse_event(self, event: str, payload: Dict[str, Any]) -> None:
528 self.wfile.write(_sse_bytes(event, payload))

Callers 2

do_GETMethod · 0.95
do_POSTMethod · 0.95

Calls 3

_send_jsonMethod · 0.95
_queryFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected