<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def guess_mimetype(filename):
 """Guesses the mimetype of a file based on the given ``filename``. .. code-block:: python 'text/plain' 'application/octet-stream' Parameters filename : str The file name or path for which the mimetype is to be guessed """

    fn = os.path.basename(filename)
    return mimetypes.guess_type(fn)[0] or 'application/octet-stream'