MIME_TYPES = {
    '.png': 'image/png',
    '.jpg': 'image/jpeg',
    '.jpeg': 'image/jpeg',
    '.gif': 'image/gif',
}


def to_mimetype(ext):
    if ext.lower() in MIME_TYPES:
        return MIME_TYPES[ext.lower()]

MIME_TYPES = {
    '.png': 'image/png',
    '.jpg': 'image/jpeg',
    '.jpeg': 'image/jpeg',
    '.gif': 'image/gif',
    '.txt': 'text/plain',
}


def to_mimetype(ext):
    if ext.lower() in MIME_TYPES:
        return MIME_TYPES[ext.lower()]
    else:
        return "application/octet-stream"

Fix mimetype detection to handle more types.
Fix mimetype detection to handle more types.

  MIME_TYPES = {
      '.png': 'image/png',
      '.jpg': 'image/jpeg',
      '.jpeg': 'image/jpeg',
      '.gif': 'image/gif',
+     '.txt': 'text/plain',
  }
  
  
  def to_mimetype(ext):
      if ext.lower() in MIME_TYPES:
          return MIME_TYPES[ext.lower()]
+     else:
+         return "application/octet-stream"
  
Fix mimetype detection to handle more types.
## Code Before:
MIME_TYPES = {
    '.png': 'image/png',
    '.jpg': 'image/jpeg',
    '.jpeg': 'image/jpeg',
    '.gif': 'image/gif',
}


def to_mimetype(ext):
    if ext.lower() in MIME_TYPES:
        return MIME_TYPES[ext.lower()]

## Instruction:
Fix mimetype detection to handle more types.
## Code After:
MIME_TYPES = {
    '.png': 'image/png',
    '.jpg': 'image/jpeg',
    '.jpeg': 'image/jpeg',
    '.gif': 'image/gif',
    '.txt': 'text/plain',
}


def to_mimetype(ext):
    if ext.lower() in MIME_TYPES:
        return MIME_TYPES[ext.lower()]
    else:
        return "application/octet-stream"
