(self, data, code=200)
| 2350 | self.end_headers() |
| 2351 | |
| 2352 | def send_json(self, data, code=200): |
| 2353 | try: |
| 2354 | body = json.dumps(data, ensure_ascii=False).encode() |
| 2355 | self.send_response(code) |
| 2356 | self.send_header('Content-Type', 'application/json; charset=utf-8') |
| 2357 | self.send_header('Content-Length', str(len(body))) |
| 2358 | cors_headers(self) |
| 2359 | self.end_headers() |
| 2360 | self.wfile.write(body) |
| 2361 | except (BrokenPipeError, ConnectionResetError): |
| 2362 | pass |
| 2363 | |
| 2364 | def send_file(self, path: pathlib.Path, mime='text/html; charset=utf-8'): |
| 2365 | if not path.exists(): |
no test coverage detected