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

Method send_json

dashboard/server.py:2352–2362  ·  view source on GitHub ↗
(self, data, code=200)

Source from the content-addressed store, hash-verified

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():

Callers 7

_check_authMethod · 0.95
do_GETMethod · 0.95
do_POSTMethod · 0.95
_relay_eventsFunction · 0.80
_handle_client_messagesFunction · 0.80
task_websocketFunction · 0.80
broadcastFunction · 0.80

Calls 1

cors_headersFunction · 0.85

Tested by

no test coverage detected