<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find_response_format(allowed_response_formats):
 """ Basic content negotiation logic. If the 'Accept' header doesn't exactly match a format we can handle, we return JSON """

    # allowed formats default to [] before this
    if not allowed_response_formats:
        allowed_response_formats = [ResponseFormats.JSON]

    content_type = request.headers.get("Accept")
    if content_type is None:
        # Nothing specified, default to endpoint definition
        if allowed_response_formats:
            return allowed_response_formats[0]
        # Finally, default to JSON
        return ResponseFormats.JSON

    for response_format in ResponseFormats.prioritized():
        if response_format not in allowed_response_formats:
            continue
        if response_format.matches(content_type):
            return response_format

    # fallback for previous behavior
    return ResponseFormats.JSON