blob: a35f66a2f655d2743cfe410bdf6436b0c4b68614 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
""" Module defining helpers to craft answers to be sent to clients. """
from typing import Any
import json
def error(msg: str, code: int = 255) -> str:
""" Generate an error. """
return json.dumps({'type': 'response', 'content': {'status': code, 'info': msg}})
def success(obj: Any) -> str:
""" Generate a success message. """
return json.dumps({'type': 'response', 'content': {'status': 0, 'result': obj}})
|