Skip to main content

Send JSON

Sends a JSON response back to the client.

from abstra.hooks import send_json

send_json(data={'ok': True}, status_code=200, headers={"ABSTRA": "CLOUD"})

Function definition

def send_json(data=None, status_code=200, headers=None, local_file=None) -> None:

Parameters

Keyword ArgumentsDescription
data (any serializable value)Data to be serialized and sent back
status_code (number)Http response status code
headers (dict)Headers to be sent back, in addition to content-type: application/json
local_file (string)Fallback file location for testing locally

Returns

None