Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Use the mimetypes module to lookup the type for an extension.

This function also adds some extensions required for HTML5

        def guessMimeType(url):
    """Use the mimetypes module to lookup the type for an extension.
    
    This function also adds some extensions required for HTML5
    """
    (mimetype, _mimeencoding) = mimetypes.guess_type(url)
#    print "mimetype(%s): %r, %r" % (url, mimetype, _mimeencoding)
    if not mimetype:
        ext = os.path.splitext(url)[1]
#        mimetype = _MIME_TYPES[ext]
        mimetype = _MIME_TYPES.get(ext)
        debug("mimetype(%s): %r" % (url, mimetype))
    if not mimetype:
        mimetype = "application/octet-stream" 
#    print "mimetype(%s): return %r" % (url, mimetype)   
    return mimetype
        


src/w/s/WsgiDAV-1.1.0/wsgidav/fs_dav_provider.py   WsgiDAV(Download)
#        print "mimetype(%s): return %r" % (self.path, mimetype)
#        return mimetype
        return util.guessMimeType(self.path)
    def getCreationDate(self):
        return self.filestat[stat.ST_CTIME]

src/w/s/wsgidav-HEAD/wsgidav/fs_dav_provider.py   wsgidav(Download)
#        print "mimetype(%s): return %r" % (self.path, mimetype)
#        return mimetype
        return util.guessMimeType(self.path)
    def getCreationDate(self):
        return self.filestat[stat.ST_CTIME]