MCPcopy
hub / github.com/cft0808/edict / send_file

Method send_file

dashboard/server.py:2364–2377  ·  view source on GitHub ↗
(self, path: pathlib.Path, mime='text/html; charset=utf-8')

Source from the content-addressed store, hash-verified

2362 pass
2363
2364 def send_file(self, path: pathlib.Path, mime='text/html; charset=utf-8'):
2365 if not path.exists():
2366 self.send_error(404)
2367 return
2368 try:
2369 body = path.read_bytes()
2370 self.send_response(200)
2371 self.send_header('Content-Type', mime)
2372 self.send_header('Content-Length', str(len(body)))
2373 cors_headers(self)
2374 self.end_headers()
2375 self.wfile.write(body)
2376 except (BrokenPipeError, ConnectionResetError):
2377 pass
2378
2379 def _serve_static(self, rel_path):
2380 """从 dist/ 目录提供静态文件。"""

Callers 2

_serve_staticMethod · 0.95
do_GETMethod · 0.95

Calls 1

cors_headersFunction · 0.85

Tested by

no test coverage detected