(self, path: pathlib.Path, mime='text/html; charset=utf-8')
| 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/ 目录提供静态文件。""" |
no test coverage detected