Send a JSON response to the client.
(send: Send, data: Any, status: int = 200)
| 69 | |
| 70 | |
| 71 | async def send_json_response(send: Send, data: Any, status: int = 200) -> None: |
| 72 | """Send a JSON response to the client.""" |
| 73 | await send( |
| 74 | { |
| 75 | 'type': 'http.response.start', |
| 76 | 'status': status, |
| 77 | 'headers': [[b'content-type', b'application/json']], |
| 78 | } |
| 79 | ) |
| 80 | await send({'type': 'http.response.body', 'body': json.dumps(data, indent=2).encode()}) |
| 81 | |
| 82 | |
| 83 | async def send_html_response(send: Send, html_content: bytes, status: int = 200) -> None: |
no outgoing calls
no test coverage detected