def parse_request(url):
    """Returns a pair (route, payload), where
    route is the path to API and payload is the query string stored in a dictionary (if exists).

    Parameters
    ----------
    url : str
        the URL to be parsed.

    Returns
    -------
    tuple
        a tuple of type:
            (route, payload), if a query string is provided.
            (route, None) if there is no query string.
            (None, None) if provided url is not valid.
    """
    try:
        if '?' in url:
            route, data = url.split('?')
            data = data.split('&')
            payload = {}
            for d in data:
                key, value = d.split('=')
                payload[key] = value
            return route, payload
        else:
            return url, None
    except ValueError:
        print('Invalid route!')
        return None, None