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

Method _send_file

deployments/desktop/server.py:500–513  ·  view source on GitHub ↗
(self, path: Path)

Source from the content-addressed store, hash-verified

498 self.wfile.write(data)
499
500 def _send_file(self, path: Path) -> None:
501 if not path.exists() or not path.is_file():
502 self._send_json({"ok": False, "error": "Not found"}, status=HTTPStatus.NOT_FOUND)
503 return
504 data = path.read_bytes()
505 mime = mimetypes.guess_type(str(path))[0] or "application/octet-stream"
506 if mime.startswith("text/") or mime in {"application/javascript", "application/json"}:
507 mime = f"{mime}; charset=utf-8"
508 self.send_response(200)
509 self.send_header("Content-Type", mime)
510 self.send_header("Content-Length", str(len(data)))
511 self.send_header("Cache-Control", "no-store")
512 self.end_headers()
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)

Callers 1

do_GETMethod · 0.95

Calls 1

_send_jsonMethod · 0.95

Tested by

no test coverage detected