Skip to content

response_templates

routes.utils.response_templates

error_internal_response

error_internal_response(content=None)

Function returning Response object when Exception occures

Source code in yaptide/routes/utils/response_templates.py
18
19
20
def error_internal_response(content: dict = None) -> Response:
    """Function returning Response object when Exception occures"""
    return yaptide_response(message='Internal server error', code=500, content=content)

error_validation_response

error_validation_response(content=None)

Function returning Response object when ValidationError occures

Source code in yaptide/routes/utils/response_templates.py
13
14
15
def error_validation_response(content: dict = None) -> Response:
    """Function returning Response object when ValidationError occures"""
    return yaptide_response(message='Wrong data provided', code=400, content=content)

yaptide_response

yaptide_response(message, code, content=None)

Function returning Response object

Source code in yaptide/routes/utils/response_templates.py
 5
 6
 7
 8
 9
10
def yaptide_response(message: str, code: int, content: dict = None) -> Response:
    """Function returning Response object"""
    response_dict = {'message': html.escape(message)}
    if content:
        response_dict.update(content)
    return make_response(response_dict, code)