from urllib.parse import unquote


def build_response(req, resource_type, data):
    """
    Create a standard response for the request, uniform for all the endpoints.
    :param req: Flask object containing the incoming request
    :param resource_type: string to describe the endpoint
    :data: dictionary of data to return
    :return: output dictionary of the request
    """

    return dict(
        method=req.method,
        url=unquote(req.url),
        url_root=unquote(req.url_root),
        path=req.path,
        query_string=req.query_string.decode('utf-8'),
        resource_type=resource_type,
        data=data
    )