def _parse_accept_header(accept):
    """
    Parse the Accept header

    Return a list with 2-tuples of
    [(str(media_type), float(q_value)),] ordered by q values (descending).

    Default `q` for values that are not specified is 1.0
    """
    result = []
    if not accept:
        return result
    for media_range in accept.split(","):
        media_type, *parts = media_range.split(";")
        media_type = media_type.strip()
        if not media_type:
            continue

        q = 1.0
        for part in parts:
            (key, _, value) = part.partition("=")
            key = key.strip()
            if key == "q":
                try:
                    q = float(value)
                except ValueError:
                    pass
                break
        result.append((media_type, q))
    result.sort(key=itemgetter(1), reverse=True)
    return result
Parse the Accept header

Return a list with 2-tuples of
[(str(media_type), float(q_value)),] ordered by q values (descending).

Default `q` for values that are not specified is 1.0
jupyterhub/utils.py