MCPcopy Create free account
hub / github.com/FastLED/FastLED / send_json_response

Method send_json_response

examples/Asio/Client/test_server.py:33–41  ·  view source on GitHub ↗

Send JSON response with appropriate headers.

(self, data: dict[str, Any], status_code: int = 200)

Source from the content-addressed store, hash-verified

31 )
32
33 def send_json_response(self, data: dict[str, Any], status_code: int = 200) -> None:
34 """Send JSON response with appropriate headers."""
35 json_data = json.dumps(data, indent=2)
36 self.send_response(status_code)
37 self.send_header("Content-Type", "application/json")
38 self.send_header("Content-Length", str(len(json_data)))
39 self.send_header("Access-Control-Allow-Origin", "*")
40 self.end_headers()
41 self.wfile.write(json_data.encode())
42
43 def send_text_response(self, text: str, status_code: int = 200) -> None:
44 """Send plain text response."""

Callers 2

do_GETMethod · 0.95
do_POSTMethod · 0.95

Calls 3

send_responseMethod · 0.80
end_headersMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected