#coding: utf8
import os

MIMETYPES = {'.zirz': 'application/vnd.zul', '.conf': 'text/plain', '.obd': 'application/x-msbinder',
             '.obj': 'application/octet-stream', '.dtshd': 'audio/vnd.dts.hd', '.silo': 'model/mesh',
             '.cryptonote': 'application/vnd.rig.cryptonote', '.pml': 'application/vnd.ctc-posml',
             '.f4v': 'video/x-f4v', '.iso': 'application/octet-stream', '.hvs': 'application/vnd.yamaha.hv-script',
             '.ras': 'image/x-cmu-raster', '.rar': 'application/x-rar-compressed', '.mrc': 'application/marc',
             '.sdkd': 'application/vnd.solent.sdkm+xml', '.bcpio': 'application/x-bcpio', '.asf': 'video/x-ms-asf',
             '.sdkm': 'application/vnd.solent.sdkm+xml', '.list3820': 'application/vnd.ibm.modcap',
             '.ecelp7470': 'audio/vnd.nuera.ecelp7470', '.fh5': 'image/x-freehand', '.bz': 'application/x-bzip',
             '.onetoc2': 'application/onenote', '.ait': 'application/vnd.dvb.ait', '.onetmp': 'application/onenote',
             '.bmp': 'image/bmp', '.geo': 'application/vnd.dynageo',
             '.air': 'application/vnd.adobe.air-application-installer-package+zip', '.bmi': 'application/vnd.bmi',
             '.jad': 'text/vnd.sun.j2me.app-descriptor', '.xhvml': 'application/xv+xml', '.dvi': 'application/x-dvi',
             '.aif': 'audio/x-aiff', '.eps': 'application/postscript', '.hpid': 'application/vnd.hp-hpid',
             '.ott': 'application/vnd.oasis.opendocument.text-template', '.rss': 'application/rss+xml',
             '.ots': 'application/vnd.oasis.opendocument.spreadsheet-template', '.hlp': 'application/winhlp',
             '.cst': 'application/x-director', '.p10': 'application/pkcs10', '.csv': 'text/csv',
             '.p12': 'application/x-pkcs12', '.csp': 'application/vnd.commonspace',
             '.sus': 'application/vnd.sus-calendar', '.css': 'text/css', '.npx': 'image/vnd.net-fpx',
             '.otg': 'application/vnd.oasis.opendocument.graphics-template', '.otf': 'application/x-font-otf',
             '.csh': 'application/x-csh', '.otc': 'application/vnd.oasis.opendocument.chart-template',
             '.pdb': 'application/vnd.palm', '.clkp': 'application/vnd.crick.clicker.palette',
             '.pdf': 'application/pdf', '.hal': 'application/vnd.hal+xml', '.pl': 'text/plain',
             '.atomsvc': 'application/atomsvc+xml', '.xul': 'application/vnd.mozilla.xul+xml',
             '.chm': 'application/vnd.ms-htmlhelp', '.djv': 'image/vnd.djvu', '.py': 'text/x-python',
             '.ttf': 'application/x-font-ttf', '.xml': 'application/xml', '.ps': 'application/postscript',
             '.htm': 'text/html', '.m2a': 'audio/mpeg', '.fig': 'application/x-xfig',
             '.sig': 'application/pgp-signature', '.cab': 'application/vnd.ms-cab-compressed',
             '.tsv': 'text/tab-separated-values', '.uvp': 'video/vnd.dece.pd', '.xlm': 'application/vnd.ms-excel',
             '.ltf': 'application/vnd.frogans.ltf', '.xlb': 'application/vnd.ms-excel',
             '.prc': 'application/x-mobipocket-ebook', '.pre': 'application/vnd.lotus-freelance',
             '.prf': 'application/pics-rules', '.car': 'application/vnd.curl.car',
             '.tsd': 'application/timestamped-data', '.dd2': 'application/vnd.oma.dd2+xml',
             '.cat': 'application/vnd.ms-pki.seccat', '.dms': 'application/octet-stream',
             '.sc': 'application/vnd.ibm.secure-container', '.ief': 'image/ief', '.mp4s': 'application/mp4',
             '.uvs': 'video/vnd.dece.sd', '.jpgm': 'video/jpm', '.c4d': 'application/vnd.clonk.c4group',
             '.c4g': 'application/vnd.clonk.c4group', '.c4f': 'application/vnd.clonk.c4group',
             '.texinfo': 'application/x-texinfo', '.p8': 'application/pkcs8', '.dmg': 'application/octet-stream',
             '.c4p': 'application/vnd.clonk.c4group', '.c4u': 'application/vnd.clonk.c4group',
             '.vis': 'application/vnd.visionary', '.viv': 'video/vnd.vivo', '.ddd': 'application/vnd.fujixerox.ddd',
             '.link66': 'application/vnd.route66.link66+xml', '.tmo': 'application/vnd.tmobile-livetv',
             '.ext': 'application/vnd.novadigm.ext', '.exi': 'application/exi', '.csml': 'chemical/x-csml',
             '.mus': 'application/vnd.musician', '.opf': 'application/oebps-package+xml',
             '.exe': 'application/x-msdownload', '.xpw': 'application/vnd.intercon.formnet',
             '.xpr': 'application/vnd.is-xpr', '.xps': 'application/vnd.ms-xpsdocument', '.dsc': 'text/prs.lines.tag',
             '.xpx': 'application/vnd.intercon.formnet', '.mscml': 'application/mediaservercontrol+xml',
             '.rep': 'application/vnd.businessobjects', '.xpm': 'image/x-xpixmap', '.mpeg': 'video/mpeg',
             '.ms': 'text/troff', '.m21': 'application/mp21', '.sisx': 'application/vnd.symbian.install',
             '.m4v': 'video/x-m4v', '.spq': 'application/scvp-vp-request', '.fxpl': 'application/vnd.adobe.fxp',
             '.ami': 'application/vnd.amiga.ami', '.fm': 'application/vnd.framemaker', '.ram': 'audio/x-pn-realaudio',
             '.dssc': 'application/dssc+der', '.fh': 'image/x-freehand', '.sgml': 'text/sgml',
             '.spf': 'application/vnd.yamaha.smaf-phrase', '.xlt': 'application/vnd.ms-excel',
             '.spc': 'application/x-pkcs7-certificates', '.spl': 'application/x-futuresplash',
             '.bat': 'application/x-msdownload', '.mgp': 'application/vnd.osgeo.mapguide.package',
             '.emma': 'application/emma+xml', '.eml': 'message/rfc822', '.lvp': 'audio/vnd.lucent.voice',
             '.fhc': 'image/x-freehand', '.gac': 'application/vnd.groove-account', '.cww': 'application/prs.cww',
             '.efif': 'application/vnd.picsel', '.yin': 'application/yin+xml', '.wad': 'application/x-doom',
             '.saf': 'application/vnd.yamaha.smaf-audio', '.txf': 'application/vnd.mobius.txf',
             '.utz': 'application/vnd.uiq.theme', '.txd': 'application/vnd.genomatix.tuxedo', '.m2v': 'video/mpeg',
             '.wrl': 'model/vrml', '.wav': 'audio/x-wav', '.rsd': 'application/rsd+xml', '.mxml': 'application/xv+xml',
             '.xsm': 'application/vnd.syncml+xml', '.xbm': 'image/x-xbitmap', '.txt': 'text/plain',
             '.jlt': 'application/vnd.hp-jlyt', '.xbd': 'application/vnd.fujixerox.docuworks.binder',
             '.wax': 'audio/x-ms-wax', '.mlp': 'application/vnd.dolby.mlp', '.qxd': 'application/vnd.quark.quarkxpress',
             '.twd': 'application/vnd.simtech-mindmapper', '.dna': 'application/vnd.dna', '.ts': 'video/mp2t',
             '.tr': 'text/troff', '.distz': 'application/octet-stream', '.ahead': 'application/vnd.ahead.space',
             '.smil': 'application/smil+xml', '.fnc': 'application/vnd.frogans.fnc',
             '.et3': 'application/vnd.eszigno3+xml', '.xif': 'image/vnd.xiff', '.dae': 'model/vnd.collada+xml',
             '.daf': 'application/vnd.mobius.daf', '.cer': 'application/pkix-cert',
             '.smf': 'application/vnd.stardivision.math', '.ufd': 'application/vnd.ufdl',
             '.dotm': 'application/vnd.ms-word.template.macroenabled.12', '.smi': 'application/smil+xml',
             '.uu': 'text/x-uuencode', '.3gp': 'video/3gpp', '.pub': 'application/x-mspublisher',
             '.gxt': 'application/vnd.geonext', '.jisp': 'application/vnd.jisp', '.sfs': 'application/vnd.spotfire.sfs',
             '.imp': 'application/vnd.accpac.simply.imp', '.mpn': 'application/vnd.mophun.application',
             '.etx': 'text/x-setext', '.jpgv': 'video/jpeg', '.iges': 'model/iges', '.ogv': 'video/ogg',
             '.movie': 'video/x-sgi-movie', '.dxp': 'application/vnd.spotfire.dxp', '.png': 'image/png',
             '.mhtml': 'message/rfc822', '.tar': 'application/x-tar', '.pnm': 'image/x-portable-anymap',
             '.pnt': 'image/x-macpaint', '.mqy': 'application/vnd.mobius.mqy', '.asm': 'text/x-asm',
             '.dxf': 'image/vnd.dxf', '.rnc': 'application/relax-ng-compact-syntax',
             '.tao': 'application/vnd.tao.intent-module-archive',
             '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.wvx': 'video/x-ms-wvx',
             '.wgt': 'application/widget', '.hpgl': 'application/vnd.hp-hpgl', '.ktx': 'image/ktx',
             '.dotx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
             '.ecelp9600': 'audio/vnd.nuera.ecelp9600', '.cu': 'application/cu-seeme',
             '.chrt': 'application/vnd.kde.kchart', '.wsdl': 'application/wsdl+xml', '.dwg': 'image/vnd.dwg',
             '.dwf': 'model/vnd.dwf', '.fg5': 'application/vnd.fujitsu.oasysgp', '.dcurl': 'text/vnd.curl.dcurl',
             '.gex': 'application/vnd.geometry-explorer', '.ei6': 'application/vnd.pg.osasli',
             '.xlsb': 'application/vnd.ms-excel.sheet.binary.macroenabled.12', '.mcd': 'application/vnd.mcd',
             '.odft': 'application/vnd.oasis.opendocument.formula-template',
             '.nnd': 'application/vnd.noblenet-directory', '.pgn': 'application/x-chess-pgn',
             '.mwf': 'application/vnd.mfer', '.str': 'application/vnd.pg.format', '.g2w': 'application/vnd.geoplan',
             '.stw': 'application/vnd.sun.xml.writer.template', '.sti': 'application/vnd.sun.xml.impress.template',
             '.nns': 'application/vnd.noblenet-sealer', '.stk': 'application/hyperstudio',
             '.crl': 'application/pkix-crl', '.ipfix': 'application/ipfix', '.stl': 'application/vnd.ms-pki.stl',
             '.semf': 'application/vnd.semf', '.bed': 'application/vnd.realvnc.bed',
             '.stc': 'application/vnd.sun.xml.calc.template', '.crd': 'application/x-mscardfile',
             '.std': 'application/vnd.sun.xml.draw.template', '.m1v': 'video/mpeg', '.stf': 'application/vnd.wt.stf',
             '.gmx': 'application/vnd.gmx', '.ifb': 'text/calendar', '.avi': 'video/x-msvideo',
             '.fgd': 'application/x-director', '.dp': 'application/vnd.osgi.dp', '.mrcx': 'application/marcxml+xml',
             '.cla': 'application/vnd.claymore', '.pwn': 'application/vnd.3m.post-it-notes', '.wml': 'text/vnd.wap.wml',
             '.mht': 'message/rfc822', '.pskcxml': 'application/pskc+xml', '.wma': 'audio/x-ms-wma',
             '.wmf': 'application/x-msmetafile', '.wmd': 'application/x-ms-wmd', '.mcurl': 'text/vnd.curl.mcurl',
             '.wmz': 'application/x-ms-wmz', '.clp': 'application/x-msclip', '.wmx': 'video/x-ms-wmx',
             '.rp9': 'application/vnd.cloanto.rp9', '.mc1': 'application/vnd.medcalcdata',
             '.m13': 'application/x-msmediaview', '.m14': 'application/x-msmediaview',
             '.dist': 'application/octet-stream', '.mp4a': 'audio/mp4', '.nml': 'application/vnd.enliven',
             '.kpt': 'application/vnd.kde.kpresenter', '.uvg': 'image/vnd.dece.graphic',
             '.kpr': 'application/vnd.kde.kpresenter', '.dra': 'audio/vnd.dra', '.g3w': 'application/vnd.geospace',
             '.oa2': 'application/vnd.fujitsu.oasys2', '.oa3': 'application/vnd.fujitsu.oasys3',
             '.gtar': 'application/x-gtar', '.p7m': 'application/pkcs7-mime', '.nws': 'message/rfc822',
             '.deb': 'application/x-debian-package', '.p7c': 'application/pkcs7-mime',
             '.p7b': 'application/x-pkcs7-certificates', '.def': 'text/plain', '.jp2': 'image/jp2',
             '.mts': 'model/vnd.mts', '.bpk': 'application/octet-stream', '.ez': 'application/andrew-inset',
             '.der': 'application/x-x509-ca-cert', '.p7s': 'application/pkcs7-signature',
             '.p7r': 'application/x-pkcs7-certreqresp', '.pntg': 'image/x-macpaint', '.ico': 'image/x-icon',
             '.fxp': 'application/vnd.adobe.fxp', '.acc': 'application/vnd.americandynamics.acc',
             '.bdf': 'application/x-font-bdf', '.c11amz': 'application/vnd.cluetrust.cartomobile-config-pkg',
             '.ace': 'application/x-ace-compressed', '.rmi': 'audio/midi', '.listafp': 'application/vnd.ibm.modcap',
             '.dfac': 'application/vnd.dreamfactory', '.acu': 'application/vnd.acucobol',
             '.wmlsc': 'application/vnd.wap.wmlscriptc', '.oas': 'application/vnd.fujitsu.oasys',
             '.c11amc': 'application/vnd.cluetrust.cartomobile-config', '.tex': 'application/x-tex',
             '.wri': 'application/x-mswrite', '.mesh': 'model/mesh', '.irp': 'application/vnd.irepository.package+xml',
             '.ecma': 'application/ecmascript', '.sse': 'application/vnd.kodak-descriptor',
             '.ssf': 'application/vnd.epson.ssf', '.sitx': 'application/x-stuffitx',
             '.oth': 'application/vnd.oasis.opendocument.text-web', '.tei': 'application/tei+xml',
             '.rtx': 'text/richtext', '.qtif': 'image/x-quicktime', '.uvv': 'video/vnd.dece.video',
             '.meta4': 'application/metalink4+xml', '.irm': 'application/vnd.ibm.rights-management',
             '.ice': 'x-conference/x-cooltalk', '.joda': 'application/vnd.joost.joda-archive',
             '.rpst': 'application/vnd.nokia.radio-preset', '.fdf': 'application/vnd.fdf',
             '.elc': 'application/octet-stream', '.eot': 'application/vnd.ms-fontobject',
             '.rpss': 'application/vnd.nokia.radio-presets', '.hps': 'application/vnd.hp-hps',
             '.mfm': 'application/vnd.mfmp', '.wbmp': 'image/vnd.wap.wbmp', '.in': 'text/plain',
             '.pas': 'text/x-pascal', '.sub': 'image/vnd.dvb.subtitle', '.paw': 'application/vnd.pawaafile',
             '.fbs': 'image/vnd.fastbidsheet', '.lrf': 'application/octet-stream',
             '.gim': 'application/vnd.groove-identity-message', '.kfo': 'application/vnd.kde.kformula',
             '.ims': 'application/vnd.ms-ims', '.gif': 'image/gif', '.lrm': 'application/vnd.ms-lrm',
             '.cdkey': 'application/vnd.mediastation.cdkey', '.atomcat': 'application/atomcat+xml',
             '.qwd': 'application/vnd.quark.quarkxpress', '.i2g': 'application/vnd.intergeo', '.rtf': 'application/rtf',
             '.mov': 'video/quicktime', '.twds': 'application/vnd.simtech-mindmapper', '.dxr': 'application/x-director',
             '.azw': 'application/vnd.amazon.ebook', '.qxt': 'application/vnd.quark.quarkxpress',
             '.azs': 'application/vnd.airzip.filesecure.azs', '.iif': 'application/vnd.shana.informed.interchange',
             '.sv4cpio': 'application/x-sv4cpio', '.ngdat': 'application/vnd.nokia.n-gage.data',
             '.azf': 'application/vnd.airzip.filesecure.azf', '.com': 'application/x-msdownload',
             '.wbxml': 'application/vnd.wap.wbxml', '.hh': 'text/x-c', '.mathml': 'application/mathml+xml',
             '.rmp': 'audio/x-pn-realaudio-plugin', '.wiz': 'application/msword', '.vcd': 'application/x-cdlink',
             '.vcg': 'application/vnd.groove-vcard', '.vcf': 'text/x-vcard', '.json': 'application/json',
             '.shf': 'application/shf+xml', '.cdbcmsg': 'application/vnd.contact.cmsg',
             '.tpt': 'application/vnd.trid.tpt', '.psb': 'application/vnd.3gpp.pic-bw-small',
             '.vxml': 'application/voicexml+xml', '.psf': 'application/x-font-linux-psf',
             '.tpl': 'application/vnd.groove-tool-template', '.htke': 'application/vnd.kenameaapp',
             '.vcx': 'application/vnd.vcx', '.teicorpus': 'application/tei+xml', '.xhtml': 'application/xhtml+xml',
             '.midi': 'audio/midi', '.tiff': 'image/tiff', '.cdmio': 'application/cdmi-object',
             '.texi': 'application/x-texinfo', '.oda': 'application/oda', '.ustar': 'application/x-ustar',
             '.ssml': 'application/ssml+xml', '.odb': 'application/vnd.oasis.opendocument.database',
             '.m3u8': 'application/x-mpegurl', '.cdmid': 'application/cdmi-domain', '.see': 'application/vnd.seemail',
             '.cdmia': 'application/cdmi-capability', '.fcs': 'application/vnd.isac.fcs',
             '.mpkg': 'application/vnd.apple.installer+xml', '.manifest': 'text/cache-manifest',
             '.odt': 'application/vnd.oasis.opendocument.text', '.3g2': 'video/3gpp2',
             '.odp': 'application/vnd.oasis.opendocument.presentation',
             '.ods': 'application/vnd.oasis.opendocument.spreadsheet', '.cdmiq': 'application/cdmi-queue',
             '.text': 'text/plain', '.qt': 'video/quicktime', '.mpm': 'application/vnd.blueice.multipass',
             '.mpc': 'application/vnd.mophun.certificate', '.mpa': 'video/mpeg', '.mpg': 'video/mpeg',
             '.mpe': 'video/mpeg', '.xdssc': 'application/dssc+xml', '.mpy': 'application/vnd.ibm.minipay',
             '.pot': 'application/vnd.ms-powerpoint', '.umj': 'application/vnd.umajin',
             '.wpd': 'application/vnd.wordperfect', '.tfi': 'application/thraud+xml',
             '.mpp': 'application/vnd.ms-project', '.tfm': 'application/x-tex-tfm', '.xspf': 'application/xspf+xml',
             '.nsf': 'application/vnd.lotus-notes', '.wmlc': 'application/vnd.wap.wmlc',
             '.ggb': 'application/vnd.geogebra.file', '.webp': 'image/webp', '.pyv': 'video/vnd.ms-playready.media.pyv',
             '.dpg': 'application/vnd.dpgraph', '.fzs': 'application/vnd.fuzzysheet',
             '.ggt': 'application/vnd.geogebra.tool', '.onetoc': 'application/onenote', '.webm': 'video/webm',
             '.kon': 'application/vnd.kde.kontour', '.karbon': 'application/vnd.kde.karbon', '.weba': 'audio/webm',
             '.pfx': 'application/x-pkcs12', '.m4a': 'audio/mp4a-latm', '.mseq': 'application/vnd.mseq',
             '.ivp': 'application/vnd.immervision-ivp', '.ivu': 'application/vnd.immervision-ivu',
             '.qti': 'image/x-quicktime', '.pfr': 'application/font-tdpfr', '.yang': 'application/yang',
             '.swa': 'application/x-director', '.gv': 'text/vnd.graphviz', '.swf': 'application/x-shockwave-flash',
             '.m4p': 'audio/mp4a-latm', '.mp3': 'audio/mpeg', '.swi': 'application/vnd.aristanetworks.swi',
             '.sldm': 'application/vnd.ms-powerpoint.slide.macroenabled.12', '.pfa': 'application/x-font-type1',
             '.pfb': 'application/x-font-type1', '.mp4': 'video/mp4', '.hvp': 'application/vnd.yamaha.hv-voice',
             '.rm': 'application/vnd.rn-realmedia', '.rl': 'application/resource-lists+xml',
             '.pkg': 'application/octet-stream', '.ra': 'audio/x-pn-realaudio', '.sbml': 'application/sbml+xml',
             '.seed': 'application/vnd.fdsn.seed', '.book': 'application/vnd.framemaker', '.cmdf': 'chemical/x-cmdf',
             '.wcm': 'application/vnd.ms-works', '.sxd': 'application/vnd.sun.xml.draw',
             '.rs': 'application/rls-services+xml', '.ppam': 'application/vnd.ms-powerpoint.addin.macroenabled.12',
             '.rq': 'application/sparql-query', '.sxg': 'application/vnd.sun.xml.writer.global',
             '.xop': 'application/xop+xml', '.skd': 'application/vnd.koan', '.xdf': 'application/xcap-diff+xml',
             '.sis': 'application/vnd.symbian.install', '.h263': 'video/h263', '.skm': 'application/vnd.koan',
             '.h261': 'video/h261', '.osfpvg': 'application/vnd.yamaha.openscoreformat.osfpvg+xml',
             '.h264': 'video/h264', '.skt': 'application/vnd.koan', '.skp': 'application/vnd.koan',
             '.ufdl': 'application/vnd.ufdl', '.for': 'text/x-fortran', '.cct': 'application/x-director',
             '.hqx': 'application/mac-binhex40', '.ttl': 'text/turtle', '.ksp': 'application/vnd.kde.kspread',
             '.sit': 'application/x-stuffit', '.doc': 'application/msword', '.srx': 'application/sparql-results+xml',
             '.wps': 'application/vnd.ms-works', '.shar': 'application/x-shar', '.psd': 'image/vnd.adobe.photoshop',
             '.ptid': 'application/vnd.pvi.ptid1', '.m3u': 'audio/x-mpegurl', '.cxt': 'application/x-director',
             '.ksh': 'text/plain', '.ccxml': 'application/ccxml+xml', '.dot': 'application/msword',
             '.cdy': 'application/vnd.cinderella', '.cdx': 'chemical/x-cdx', '.slt': 'application/vnd.epson.salt',
             '.fvt': 'video/vnd.fvt', '.vor': 'application/vnd.stardivision.writer', '.ics': 'text/calendar',
             '.vox': 'application/x-authorware-bin', '.ktr': 'application/vnd.kahootz',
             '.qps': 'application/vnd.publishare-delta-tree', '.gsf': 'application/x-font-ghostscript',
             '.icm': 'application/vnd.iccprofile', '.uoml': 'application/vnd.uoml+xml',
             '.icc': 'application/vnd.iccprofile', '.ktz': 'application/vnd.kahootz', '.uri': 'text/uri-list',
             '.cdf': 'application/x-netcdf', '.ai': 'application/postscript', '.deploy': 'application/octet-stream',
             '.mp4v': 'video/mp4', '.grv': 'application/vnd.groove-injector', '.list': 'text/plain',
             '.esf': 'application/vnd.epson.esf', '.abw': 'application/x-abiword',
             '.wspolicy': 'application/wspolicy+xml', '.mpga': 'audio/mpeg', '.epub': 'application/epub+zip',
             '.pki': 'application/pkixcmp', '.cc': 'text/x-c', '.hdf': 'application/x-hdf',
             '.davmount': 'application/davmount+xml', '.xpdl': 'application/xml', '.src': 'application/x-wais-source',
             '.zaz': 'application/vnd.zzazz.deck+xml', '.bdm': 'application/vnd.syncml.dm+wbxml',
             '.wqd': 'application/vnd.wqd', '.log': 'text/plain', '.cxx': 'text/x-c',
             '.mobipocket-ebook': 'application/octet-stream', '.box': 'application/vnd.previewsystems.box',
             '.sru': 'application/sru+xml', '.boz': 'application/x-bzip2', '.vcs': 'text/x-vcalendar',
             '.oxt': 'application/vnd.openofficeorg.extension', '.pbd': 'application/vnd.powerbuilder6',
             '.bh2': 'application/vnd.fujitsu.oasysprs', '.mpg4': 'video/mp4',
             '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
             '.djvu': 'image/vnd.djvu', '.pbm': 'image/x-portable-bitmap', '.es3': 'application/vnd.eszigno3+xml',
             '.qbo': 'application/vnd.intu.qbo', '.vrml': 'model/vrml', '.msty': 'application/vnd.muvee.style',
             '.dtd': 'application/xml-dtd', '.dtb': 'application/x-dtbook+xml', '.pclxl': 'application/vnd.hp-pclxl',
             '.xdp': 'application/vnd.adobe.xdp+xml', '.xdw': 'application/vnd.fujixerox.docuworks',
             '.onepkg': 'application/onenote', '.mobi': 'application/x-mobipocket-ebook',
             '.mbk': 'application/vnd.mobius.mbk', '.cdxml': 'application/vnd.chemdraw+xml', '.kar': 'audio/midi',
             '.ipk': 'application/vnd.shana.informed.package', '.org': 'application/vnd.lotus-organizer',
             '.gre': 'application/vnd.geometry-explorer', '.xslt': 'application/xslt+xml', '.aiff': 'audio/x-aiff',
             '.aifc': 'audio/x-aiff', '.xdm': 'application/vnd.syncml.dm+xml', '.gqf': 'application/vnd.grafeq',
             '.mp21': 'application/mp21', '.flx': 'text/vnd.fmi.flexstor', '.fly': 'text/vnd.fly',
             '.kne': 'application/vnd.kinar', '.edx': 'application/vnd.novadigm.edx', '.flv': 'video/x-flv',
             '.flw': 'application/vnd.kde.kivio', '.odg': 'application/vnd.oasis.opendocument.graphics',
             '.susp': 'application/vnd.sus-calendar', '.ez3': 'application/vnd.ezpix-package',
             '.ez2': 'application/vnd.ezpix-album', '.gqs': 'application/vnd.grafeq',
             '.nbp': 'application/vnd.wolfram.player', '.hbci': 'application/vnd.hbci',
             '.pkipath': 'application/pkix-pkipath', '.uvvd': 'application/vnd.dece.data',
             '.odc': 'application/vnd.oasis.opendocument.chart', '.uvvf': 'application/vnd.dece.data',
             '.sema': 'application/vnd.sema', '.uvvh': 'video/vnd.dece.hd', '.uvvi': 'image/vnd.dece.graphic',
             '.ppt': 'application/vnd.ms-powerpoint', '.pps': 'application/vnd.ms-powerpoint',
             '.uvvp': 'video/vnd.dece.pd', '.odm': 'application/vnd.oasis.opendocument.text-master',
             '.ppm': 'image/x-portable-pixmap', '.lzh': 'application/octet-stream', '.uvvu': 'video/vnd.uvvu.mp4',
             '.uvvv': 'video/vnd.dece.video', '.xvm': 'application/xv+xml', '.latex': 'application/x-latex',
             '.semd': 'application/vnd.semd', '.ppd': 'application/vnd.cups-ppd', '.cgm': 'image/cgm',
             '.ppa': 'application/vnd.ms-powerpoint', '.fpx': 'image/vnd.fpx', '.igl': 'application/vnd.igloader',
             '.mbox': 'application/mbox', '.lwp': 'application/vnd.lotus-wordpro',
             '.osf': 'application/vnd.yamaha.openscoreformat', '.gdl': 'model/vnd.gdl',
             '.odi': 'application/vnd.oasis.opendocument.image', '.kwt': 'application/vnd.kde.kword',
             '.dcr': 'application/x-director', '.oti': 'application/vnd.oasis.opendocument.image-template',
             '.mp2a': 'audio/mpeg', '.cdmic': 'application/cdmi-container', '.igx': 'application/vnd.micrografx.igx',
             '.kwd': 'application/vnd.kde.kword', '.igs': 'model/iges', '.apr': 'application/vnd.lotus-approach',
             '.crt': 'application/x-x509-ca-cert', '.n-gage': 'application/vnd.nokia.n-gage.symbian.install',
             '.tcl': 'application/x-tcl', '.ogx': 'application/ogg', '.flo': 'application/vnd.micrografx.flo',
             '.jam': 'application/vnd.jam', '.rlc': 'image/vnd.fujixerox.edmics-rlc',
             '.rld': 'application/resource-lists-diff+xml', '.svgz': 'image/svg+xml', '.bz2': 'application/x-bzip2',
             '.xar': 'application/vnd.xara', '.jar': 'application/java-archive', '.cpt': 'application/mac-compactpro',
             '.ogg': 'audio/ogg', '.dts': 'audio/vnd.dts', '.oga': 'audio/ogg', '.afp': 'application/vnd.ibm.modcap',
             '.f90': 'text/x-fortran', '.application': 'application/x-ms-application', '.mxf': 'application/mxf',
             '.rgb': 'image/x-rgb', '.mxl': 'application/vnd.recordare.musicxml',
             '.mxs': 'application/vnd.triscape.mxs', '.gram': 'application/srgs', '.me': 'text/troff',
             '.mb': 'application/mathematica', '.mxu': 'video/vnd.mpegurl', '.ma': 'application/mathematica',
             '.qam': 'application/vnd.epson.quickanime', '.afm': 'application/x-font-type1',
             '.thmx': 'application/vnd.ms-officetheme', '.mseed': 'application/vnd.fdsn.mseed', '.fli': 'video/x-fli',
             '.asx': 'video/x-ms-asf', '.pcurl': 'application/vnd.curl.pcurl',
             '.ser': 'application/java-serialized-object', '.portpkg': 'application/vnd.macports.portpkg',
             '.vsf': 'application/vnd.vsf', '.res': 'application/x-dtbresource+xml',
             '.pgp': 'application/pgp-encrypted', '.svc': 'application/vnd.dvb.service',
             '.nlu': 'application/vnd.neurolanguage.nlu', '.pgm': 'image/x-portable-graymap', '.xyz': 'chemical/x-xyz',
             '.svg': 'image/svg+xml', '.svd': 'application/vnd.svd', '.atom': 'application/atom+xml',
             '.qfx': 'application/vnd.intu.qfx', '.roff': 'text/troff', '.unityweb': 'application/vnd.unity',
             '.123': 'application/vnd.lotus-1-2-3', '.xlsm': 'application/vnd.ms-excel.sheet.macroenabled.12',
             '.uvd': 'application/vnd.dece.data', '.xbap': 'application/x-ms-xbap', '.uvf': 'application/vnd.dece.data',
             '.uva': 'audio/vnd.dece.audio', '.uvm': 'video/vnd.dece.mobile', '.scurl': 'text/vnd.curl.scurl',
             '.uvi': 'image/vnd.dece.graphic', '.uvh': 'video/vnd.dece.hd', '.eol': 'audio/vnd.digital-winds',
             '.frame': 'application/vnd.framemaker', '.uvu': 'video/vnd.uvvu.mp4',
             '.uvt': 'application/vnd.dece.ttml+xml', '.lostxml': 'application/lost+xml', '.spx': 'audio/ogg',
             '.man': 'text/troff', '.mac': 'image/x-macpaint', '.uvx': 'application/vnd.dece.unspecified',
             '.mag': 'application/vnd.ecowin.chart', '.pya': 'audio/vnd.ms-playready.media.pya',
             '.pyc': 'application/x-python-code', '.atx': 'application/vnd.antix.game-component',
             '.dataless': 'application/vnd.fdsn.seed', '.apk': 'application/vnd.android.package-archive',
             '.mny': 'application/x-msmoney', '.pyo': 'application/x-python-code',
             '.ghf': 'application/vnd.groove-help', '.cpio': 'application/x-cpio',
             '.setreg': 'application/set-registration-initiation', '.atc': 'application/vnd.acucorp',
             '.cml': 'chemical/x-cml', '.ecelp4800': 'audio/vnd.nuera.ecelp4800', '.xpi': 'application/x-xpinstall',
             '.jnlp': 'application/x-java-jnlp-file', '.uvva': 'audio/vnd.dece.audio',
             '.dll': 'application/x-msdownload', '.rif': 'application/reginfo+xml', '.uvvm': 'video/vnd.dece.mobile',
             '.scq': 'application/scvp-cv-request', '.scs': 'application/scvp-cv-response',
             '.scm': 'application/vnd.lotus-screencam', '.xfdl': 'application/vnd.xfdl', '.rip': 'audio/vnd.rip',
             '.scd': 'application/x-msschedule', '.wdb': 'application/vnd.ms-works',
             '.xfdf': 'application/vnd.adobe.xfdf', '.xwd': 'image/x-xwindowdump',
             '.xlam': 'application/vnd.ms-excel.addin.macroenabled.12', '.aab': 'application/x-authorware-bin',
             '.aac': 'audio/x-aac', '.sda': 'application/vnd.stardivision.draw', '.aam': 'application/x-authorware-map',
             '.sdc': 'application/vnd.stardivision.calc', '.g3': 'image/g3fax',
             '.sdd': 'application/vnd.stardivision.impress', '.js': 'application/javascript',
             '.aas': 'application/x-authorware-seg', '.sdp': 'application/sdp',
             '.sdw': 'application/vnd.stardivision.writer', '.plb': 'application/vnd.3gpp.pic-bw-large',
             '.plc': 'application/vnd.mobius.plc', '.plf': 'application/vnd.pocketlearn', '.3dml': 'text/vnd.in3d.3dml',
             '.lha': 'application/octet-stream', '.edm': 'application/vnd.novadigm.edm',
             '.wtb': 'application/vnd.webturbo', '.msf': 'application/vnd.epson.msf', '.pls': 'application/pls+xml',
             '.knp': 'application/vnd.kinar', '.msl': 'application/vnd.mobius.msl',
             '.mpt': 'application/vnd.ms-project', '.qxb': 'application/vnd.quark.quarkxpress', '.msh': 'model/mesh',
             '.msi': 'application/x-msdownload', '.oprc': 'application/vnd.palm', '.pcf': 'application/x-font-pcf',
             '.xla': 'application/vnd.ms-excel', '.potm': 'application/vnd.ms-powerpoint.template.macroenabled.12',
             '.7z': 'application/x-7z-compressed', '.pcl': 'application/vnd.hp-pcl', '.jpe': 'image/jpeg',
             '.jpg': 'image/jpeg', '.mdb': 'application/x-msaccess', '.cmp': 'application/vnd.yellowriver-custom-menu',
             '.potx': 'application/vnd.openxmlformats-officedocument.presentationml.template', '.jpm': 'video/jpm',
             '.pcx': 'image/x-pcx', '.zir': 'application/vnd.zul', '.mdi': 'image/vnd.ms-modi',
             '.zip': 'application/zip', '.vss': 'application/vnd.visio', '.adp': 'audio/adpcm',
             '.clkk': 'application/vnd.crick.clicker.keyboard',
             '.ppsx': 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
             '.vsw': 'application/vnd.visio', '.class': 'application/java-vm', '.torrent': 'application/x-bittorrent',
             '.mmf': 'application/vnd.smaf', '.mj2': 'video/mj2', '.m3a': 'audio/mpeg',
             '.xer': 'application/patch-ops-error+xml', '.asc': 'application/pgp-signature',
             '.qxl': 'application/vnd.quark.quarkxpress', '.fh4': 'image/x-freehand', '.vsd': 'application/vnd.visio',
             '.clkx': 'application/vnd.crick.clicker', '.clkw': 'application/vnd.crick.clicker.wordbank',
             '.xo': 'application/vnd.olpc-sugar', '.clkt': 'application/vnd.crick.clicker.template',
             '.aso': 'application/vnd.accpac.simply.aso', '.mmr': 'image/vnd.fujixerox.edmics-mmr',
             '.pwz': 'application/vnd.ms-powerpoint', '.sh': 'application/x-sh',
             '.sm': 'application/vnd.stepmania.stepchart', '.hvd': 'application/vnd.yamaha.hv-dic',
             '.so': 'application/octet-stream', '.wbs': 'application/vnd.criticaltools.wbs+xml',
             '.xlc': 'application/vnd.ms-excel', '.tcap': 'application/vnd.3gpp2.tcap',
             '.sfd-hdstx': 'application/vnd.hydrostatix.sof-data', '.cif': 'chemical/x-cif',
             '.xls': 'application/vnd.ms-excel', '.cii': 'application/vnd.anser-web-certificate-issue-initiation',
             '.st': 'application/vnd.sailingtracker.track', '.xlw': 'application/vnd.ms-excel',
             '.cil': 'application/vnd.ms-artgalry', '.spp': 'application/scvp-vp-response',
             '.wmls': 'text/vnd.wap.wmlscript', '.wks': 'application/vnd.ms-works', '.wmv': 'video/x-ms-wmv',
             '.gtw': 'model/vnd.gtw', '.uvvg': 'image/vnd.dece.graphic', '.fh7': 'image/x-freehand',
             '.gtm': 'application/vnd.groove-tool-message', '.trm': 'application/x-msterminal',
             '.ppsm': 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', '.urls': 'text/uri-list',
             '.woff': 'application/x-font-woff', '.html': 'text/html', '.kia': 'application/vnd.kidspiration',
             '.odf': 'application/vnd.oasis.opendocument.formula', '.tra': 'application/vnd.trueapp',
             '.fsc': 'application/vnd.fsc.weblaunch', '.ifm': 'application/vnd.shana.informed.formdata',
             '.mime': 'message/rfc822', '.sgl': 'application/vnd.stardivision.writer-global', '.sgm': 'text/sgml',
             '.musicxml': 'application/vnd.recordare.musicxml+xml',
             '.lbd': 'application/vnd.llamagraphics.life-balance.desktop',
             '.lbe': 'application/vnd.llamagraphics.life-balance.exchange+xml', '.maker': 'application/vnd.framemaker',
             '.fst': 'image/vnd.fst', '.wm': 'video/x-ms-wm', '.tif': 'image/tiff', '.n3': 'text/n3',
             '.otp': 'application/vnd.oasis.opendocument.presentation-template', '.dv': 'video/x-dv',
             '.qwt': 'application/vnd.quark.quarkxpress', '.f77': 'text/x-fortran', '.pic': 'image/x-pict',
             '.mvb': 'application/x-msmediaview', '.les': 'application/vnd.hhe.lesson-player',
             '.uvvs': 'video/vnd.dece.sd', '.rms': 'application/vnd.jcp.javame.midlet-rms',
             '.uvvt': 'application/vnd.dece.ttml+xml', '.mets': 'application/mets+xml',
             '.dir': 'application/x-director', '.acutc': 'application/vnd.acucorp', '.rdf': 'application/rdf+xml',
             '.xsl': 'application/xml', '.sxw': 'application/vnd.sun.xml.writer', '.spot': 'text/vnd.in3d.spot',
             '.nc': 'application/x-netcdf', '.nb': 'application/mathematica', '.sxm': 'application/vnd.sun.xml.math',
             '.uvvx': 'application/vnd.dece.unspecified', '.sxi': 'application/vnd.sun.xml.impress',
             '.aep': 'application/vnd.audiograph', '.bin': 'application/octet-stream',
             '.rdz': 'application/vnd.data-vision.rdz', '.uris': 'text/uri-list',
             '.sxc': 'application/vnd.sun.xml.calc', '.h': 'text/x-c', '.ac': 'application/pkix-attr-cert',
             '.pptm': 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
             '.itp': 'application/vnd.shana.informed.formtemplate',
             '.xltm': 'application/vnd.ms-excel.template.macroenabled.12', '.o': 'application/octet-stream',
             '.a': 'application/octet-stream', '.c': 'text/x-c', '.rcprofile': 'application/vnd.ipunplugged.rcprofile',
             '.udeb': 'application/x-debian-package', '.f': 'text/x-fortran',
             '.fe_launch': 'application/vnd.denovo.fcselayout-link', '.vtu': 'model/vnd.vtu',
             '.xltx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
             '.aw': 'application/applixware', '.au': 'audio/basic', '.p': 'text/x-pascal', '.s': 'text/x-asm',
             '.t': 'text/troff', '.wpl': 'application/vnd.ms-wpl', '.cpp': 'text/x-c', '.xenc': 'application/xenc+xml',
             '.btif': 'image/prs.btif', '.gnumeric': 'application/x-gnumeric', '.mods': 'application/mods+xml',
             '.pct': 'image/x-pict', '.docm': 'application/vnd.ms-word.document.macroenabled.12',
             '.nnw': 'application/vnd.noblenet-web', '.xvml': 'application/xv+xml',
             '.x3d': 'application/vnd.hzn-3d-crossword', '.xap': 'application/x-silverlight-app',
             '.igm': 'application/vnd.insors.igm',
             '.sldx': 'application/vnd.openxmlformats-officedocument.presentationml.slide',
             '.ttc': 'application/x-font-ttf',
             '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
             '.zmm': 'application/vnd.handheld-entertainment+xml', '.sv4crc': 'application/x-sv4crc',
             '.cmc': 'application/vnd.cosmocaller', '.pfm': 'application/x-font-type1',
             '.u32': 'application/x-authorware-bin', '.m4u': 'video/vnd.mpegurl',
             '.pvb': 'application/vnd.3gpp.pic-bw-var', '.jpeg': 'image/jpeg',
             '.mgz': 'application/vnd.proteus.magazine', '.mid': 'audio/midi', '.mif': 'application/vnd.mif',
             '.chat': 'application/x-chat', '.cmx': 'image/x-cmx', '.kml': 'application/vnd.google-earth.kml+xml',
             '.dump': 'application/octet-stream', '.gph': 'application/vnd.flographit', '.xht': 'application/xhtml+xml',
             '.dif': 'video/x-dv', '.grxml': 'application/srgs+xml', '.dic': 'text/x-c',
             '.ncx': 'application/x-dtbncx+xml', '.wg': 'application/vnd.pmi.widget',
             '.kmz': 'application/vnd.google-earth.kmz', '.mp2': 'audio/mpeg', '.x32': 'application/x-authorware-bin',
             '.teacher': 'application/vnd.smart.teacher', '.dis': 'application/vnd.mobius.dis',
             '.vst': 'application/vnd.visio', '.curl': 'text/vnd.curl', '.setpay': 'application/set-payment-initiation',
             '.cod': 'application/vnd.rim.cod', '.w3d': 'application/x-director', '.snf': 'application/x-font-snf',
             '.snd': 'audio/basic', '.mmd': 'application/vnd.chipnuts.karaoke-mmd', '.pict': 'image/pict',
             '.mjp2': 'video/mj2', '.lasxml': 'application/vnd.las.las+xml', '.ftc': 'application/vnd.fluxtime.clip',
             '.pqa': 'application/vnd.palm', '.java': 'text/x-java-source',
             '.fti': 'application/vnd.anser-web-funds-transfer-initiation', '.mads': 'application/mads+xml',

             '.less':'text/less', '.sass':'text/sass', '.scss': 'text/scss',

             '.gz': 'application/gzip',
             '.md': 'application/markdown',
             '.markdown': 'application/markdown',
             '.mk': 'application/markdown',
             '.config': 'application/config',

             '.coffee': 'text/x-coffeescript',


}

def guess_type(name, default_type=''):
    if not name:
        return default_type
    ext = os.path.splitext(name)[1].lower()
    if '?' in ext:
        ext = ext.split('?')[0]
    return MIMETYPES.get(ext) or default_type