<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sanitize_mimetype(mimetype, filename=None):
 """Sanitize a MIME type so the browser does not render the file."""

    # Allow some few mime type like plain text, images and audio.
    if mimetype in MIMETYPE_WHITELIST:
        return mimetype
    # Rewrite HTML, JavaScript, CSS etc to text/plain.
    if mimetype in MIMETYPE_PLAINTEXT or \
            (filename and filename.lower() in MIMETYPE_TEXTFILES):
        return 'text/plain'
    # Default
    return 'application/octet-stream'