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

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