def accept_best_match(accept_header, mimetypes):
for mimetype_pattern, _ in _parse_and_sort_accept_header(accept_header):<EOL><INDENT>matched_types = fnmatch.filter(mimetypes, mimetype_pattern)<EOL>if matched_types:<EOL><INDENT>return matched_types[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return mimetypes[<NUM_LIT:0>]<EOL>
Return a mimetype best matched the accept headers.

    >>> accept_best_match('application/json, text/html', ['application/json', 'text/plain'])
    'application/json'

    >>> accept_best_match('application/json;q=0.5, text/*', ['application/json', 'text/plain'])
    'text/plain'