def call_handler(request):
    """
    Given a request dictionary, call the appropriate handler.
    Return a tuple of code (str), data (dict), and cookies (list).
    """

    method = request['method']
    if method not in ('GET', 'POST', 'PUT', 'DELETE'):
        return abort(405)

    path = request['path']
    handler, parameters = find_path(method, path)
    if not handler:
        return abort(404)

    try:
        return handler(request=request, **parameters)

    except Exception:
        if config['debug']:
            return 500, format_exc()
        return abort(500)
dataset/ETHPy150Open heiskr/sagefy/server/framework/index.py/call_handler/original