PageRenderTime 54ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/web2py/gluon/contenttype.py

https://gitlab.com/sunkistm/gitlab-web2py
Python | 855 lines | 846 code | 2 blank | 7 comment | 0 complexity | c4eb9910a1f475b2ad56ffe0f2bd92fa MD5 | raw file
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. | This file is part of the web2py Web Framework
  5. | Copyrighted by Massimo Di Pierro <mdipierro@cs.depaul.edu>
  6. | License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html)
  7. CONTENT_TYPE dictionary created against freedesktop.org's shared mime info
  8. database version 1.1.
  9. Deviations from official standards:
  10. - .md: application/x-genesis-rom --> text/x-markdown
  11. - .png: image/x-apple-ios-png --> image/png
  12. Additions:
  13. - .load: text/html
  14. - .json: application/json
  15. - .jsonp: application/jsonp
  16. - .pickle: application/python-pickle
  17. - .w2p': application/w2p
  18. """
  19. from gluon._compat import to_native
  20. __all__ = ['contenttype']
  21. CONTENT_TYPE = {
  22. '.123': 'application/vnd.lotus-1-2-3',
  23. '.3ds': 'image/x-3ds',
  24. '.3g2': 'video/3gpp2',
  25. '.3ga': 'video/3gpp',
  26. '.3gp': 'video/3gpp',
  27. '.3gp2': 'video/3gpp2',
  28. '.3gpp': 'video/3gpp',
  29. '.3gpp2': 'video/3gpp2',
  30. '.602': 'application/x-t602',
  31. '.669': 'audio/x-mod',
  32. '.7z': 'application/x-7z-compressed',
  33. '.a': 'application/x-archive',
  34. '.aac': 'audio/aac',
  35. '.abw': 'application/x-abiword',
  36. '.abw.crashed': 'application/x-abiword',
  37. '.abw.gz': 'application/x-abiword',
  38. '.ac3': 'audio/ac3',
  39. '.ace': 'application/x-ace',
  40. '.adb': 'text/x-adasrc',
  41. '.ads': 'text/x-adasrc',
  42. '.afm': 'application/x-font-afm',
  43. '.ag': 'image/x-applix-graphics',
  44. '.ai': 'application/illustrator',
  45. '.aif': 'audio/x-aiff',
  46. '.aifc': 'audio/x-aifc',
  47. '.aiff': 'audio/x-aiff',
  48. '.aiffc': 'audio/x-aifc',
  49. '.al': 'application/x-perl',
  50. '.alz': 'application/x-alz',
  51. '.amr': 'audio/amr',
  52. '.amz': 'audio/x-amzxml',
  53. '.ani': 'application/x-navi-animation',
  54. '.anim[1-9j]': 'video/x-anim',
  55. '.anx': 'application/annodex',
  56. '.ape': 'audio/x-ape',
  57. '.apk': 'application/vnd.android.package-archive',
  58. '.ar': 'application/x-archive',
  59. '.arj': 'application/x-arj',
  60. '.arw': 'image/x-sony-arw',
  61. '.as': 'application/x-applix-spreadsheet',
  62. '.asc': 'text/plain',
  63. '.asf': 'video/x-ms-asf',
  64. '.asp': 'application/x-asp',
  65. '.ass': 'text/x-ssa',
  66. '.asx': 'audio/x-ms-asx',
  67. '.atom': 'application/atom+xml',
  68. '.au': 'audio/basic',
  69. '.avf': 'video/x-msvideo',
  70. '.avi': 'video/x-msvideo',
  71. '.aw': 'application/x-applix-word',
  72. '.awb': 'audio/amr-wb',
  73. '.awk': 'application/x-awk',
  74. '.axa': 'audio/annodex',
  75. '.axv': 'video/annodex',
  76. '.bak': 'application/x-trash',
  77. '.bcpio': 'application/x-bcpio',
  78. '.bdf': 'application/x-font-bdf',
  79. '.bdm': 'video/mp2t',
  80. '.bdmv': 'video/mp2t',
  81. '.bib': 'text/x-bibtex',
  82. '.bin': 'application/octet-stream',
  83. '.blend': 'application/x-blender',
  84. '.blender': 'application/x-blender',
  85. '.bmp': 'image/bmp',
  86. '.bz': 'application/x-bzip',
  87. '.bz2': 'application/x-bzip',
  88. '.c': 'text/x-csrc',
  89. '.c++': 'text/x-c++src',
  90. '.cab': 'application/vnd.ms-cab-compressed',
  91. '.cap': 'application/vnd.tcpdump.pcap',
  92. '.cb7': 'application/x-cb7',
  93. '.cbl': 'text/x-cobol',
  94. '.cbr': 'application/x-cbr',
  95. '.cbt': 'application/x-cbt',
  96. '.cbz': 'application/x-cbz',
  97. '.cc': 'text/x-c++src',
  98. '.ccmx': 'application/x-ccmx',
  99. '.cdf': 'application/x-netcdf',
  100. '.cdr': 'application/vnd.corel-draw',
  101. '.cer': 'application/pkix-cert',
  102. '.cert': 'application/x-x509-ca-cert',
  103. '.cgm': 'image/cgm',
  104. '.chm': 'application/vnd.ms-htmlhelp',
  105. '.chrt': 'application/x-kchart',
  106. '.class': 'application/x-java',
  107. '.clpi': 'video/mp2t',
  108. '.cls': 'text/x-tex',
  109. '.cmake': 'text/x-cmake',
  110. '.cob': 'text/x-cobol',
  111. '.cpi': 'video/mp2t',
  112. '.cpio': 'application/x-cpio',
  113. '.cpio.gz': 'application/x-cpio-compressed',
  114. '.cpp': 'text/x-c++src',
  115. '.cr2': 'image/x-canon-cr2',
  116. '.crl': 'application/pkix-crl',
  117. '.crt': 'application/x-x509-ca-cert',
  118. '.crw': 'image/x-canon-crw',
  119. '.cs': 'text/x-csharp',
  120. '.csh': 'application/x-csh',
  121. '.css': 'text/css',
  122. '.cssl': 'text/css',
  123. '.csv': 'text/csv',
  124. '.cue': 'application/x-cue',
  125. '.cur': 'image/x-win-bitmap',
  126. '.cxx': 'text/x-c++src',
  127. '.d': 'text/x-dsrc',
  128. '.dar': 'application/x-dar',
  129. '.dbf': 'application/x-dbf',
  130. '.dc': 'application/x-dc-rom',
  131. '.dcl': 'text/x-dcl',
  132. '.dcm': 'application/dicom',
  133. '.dcr': 'image/x-kodak-dcr',
  134. '.dds': 'image/x-dds',
  135. '.deb': 'application/x-deb',
  136. '.der': 'application/x-x509-ca-cert',
  137. '.desktop': 'application/x-desktop',
  138. '.di': 'text/x-dsrc',
  139. '.dia': 'application/x-dia-diagram',
  140. '.diff': 'text/x-patch',
  141. '.divx': 'video/x-msvideo',
  142. '.djv': 'image/vnd.djvu',
  143. '.djvu': 'image/vnd.djvu',
  144. '.dmg': 'application/x-apple-diskimage',
  145. '.dmp': 'application/vnd.tcpdump.pcap',
  146. '.dng': 'image/x-adobe-dng',
  147. '.doc': 'application/msword',
  148. '.docbook': 'application/x-docbook+xml',
  149. '.docm': 'application/vnd.ms-word.document.macroenabled.12',
  150. '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  151. '.dot': 'text/vnd.graphviz',
  152. '.dotm': 'application/vnd.ms-word.template.macroenabled.12',
  153. '.dotx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
  154. '.dsl': 'text/x-dsl',
  155. '.dtd': 'application/xml-dtd',
  156. '.dts': 'audio/vnd.dts',
  157. '.dtshd': 'audio/vnd.dts.hd',
  158. '.dtx': 'text/x-tex',
  159. '.dv': 'video/dv',
  160. '.dvi': 'application/x-dvi',
  161. '.dvi.bz2': 'application/x-bzdvi',
  162. '.dvi.gz': 'application/x-gzdvi',
  163. '.dwg': 'image/vnd.dwg',
  164. '.dxf': 'image/vnd.dxf',
  165. '.e': 'text/x-eiffel',
  166. '.egon': 'application/x-egon',
  167. '.eif': 'text/x-eiffel',
  168. '.el': 'text/x-emacs-lisp',
  169. '.emf': 'image/x-emf',
  170. '.eml': 'message/rfc822',
  171. '.emp': 'application/vnd.emusic-emusic_package',
  172. '.ent': 'application/xml-external-parsed-entity',
  173. '.eps': 'image/x-eps',
  174. '.eps.bz2': 'image/x-bzeps',
  175. '.eps.gz': 'image/x-gzeps',
  176. '.epsf': 'image/x-eps',
  177. '.epsf.bz2': 'image/x-bzeps',
  178. '.epsf.gz': 'image/x-gzeps',
  179. '.epsi': 'image/x-eps',
  180. '.epsi.bz2': 'image/x-bzeps',
  181. '.epsi.gz': 'image/x-gzeps',
  182. '.epub': 'application/epub+zip',
  183. '.erl': 'text/x-erlang',
  184. '.es': 'application/ecmascript',
  185. '.etheme': 'application/x-e-theme',
  186. '.etx': 'text/x-setext',
  187. '.exe': 'application/x-ms-dos-executable',
  188. '.exr': 'image/x-exr',
  189. '.ez': 'application/andrew-inset',
  190. '.f': 'text/x-fortran',
  191. '.f4a': 'audio/mp4',
  192. '.f4b': 'audio/x-m4b',
  193. '.f4v': 'video/mp4',
  194. '.f90': 'text/x-fortran',
  195. '.f95': 'text/x-fortran',
  196. '.fb2': 'application/x-fictionbook+xml',
  197. '.fig': 'image/x-xfig',
  198. '.fits': 'image/fits',
  199. '.fl': 'application/x-fluid',
  200. '.flac': 'audio/flac',
  201. '.flc': 'video/x-flic',
  202. '.fli': 'video/x-flic',
  203. '.flv': 'video/x-flv',
  204. '.flw': 'application/x-kivio',
  205. '.fo': 'text/x-xslfo',
  206. '.fodg': 'application/vnd.oasis.opendocument.graphics-flat-xml',
  207. '.fodp': 'application/vnd.oasis.opendocument.presentation-flat-xml',
  208. '.fods': 'application/vnd.oasis.opendocument.spreadsheet-flat-xml',
  209. '.fodt': 'application/vnd.oasis.opendocument.text-flat-xml',
  210. '.for': 'text/x-fortran',
  211. '.fxm': 'video/x-javafx',
  212. '.g3': 'image/fax-g3',
  213. '.gb': 'application/x-gameboy-rom',
  214. '.gba': 'application/x-gba-rom',
  215. '.gcrd': 'text/vcard',
  216. '.ged': 'application/x-gedcom',
  217. '.gedcom': 'application/x-gedcom',
  218. '.gem': 'application/x-tar',
  219. '.gen': 'application/x-genesis-rom',
  220. '.gf': 'application/x-tex-gf',
  221. '.gg': 'application/x-sms-rom',
  222. '.gif': 'image/gif',
  223. '.glade': 'application/x-glade',
  224. '.gml': 'application/gml+xml',
  225. '.gmo': 'application/x-gettext-translation',
  226. '.gnc': 'application/x-gnucash',
  227. '.gnd': 'application/gnunet-directory',
  228. '.gnucash': 'application/x-gnucash',
  229. '.gnumeric': 'application/x-gnumeric',
  230. '.gnuplot': 'application/x-gnuplot',
  231. '.go': 'text/x-go',
  232. '.gp': 'application/x-gnuplot',
  233. '.gpg': 'application/pgp-encrypted',
  234. '.gplt': 'application/x-gnuplot',
  235. '.gra': 'application/x-graphite',
  236. '.gsf': 'application/x-font-type1',
  237. '.gsm': 'audio/x-gsm',
  238. '.gtar': 'application/x-tar',
  239. '.gv': 'text/vnd.graphviz',
  240. '.gvp': 'text/x-google-video-pointer',
  241. '.gz': 'application/gzip',
  242. '.h': 'text/x-chdr',
  243. '.h++': 'text/x-c++hdr',
  244. '.h4': 'application/x-hdf',
  245. '.h5': 'application/x-hdf',
  246. '.hdf': 'application/x-hdf',
  247. '.hdf4': 'application/x-hdf',
  248. '.hdf5': 'application/x-hdf',
  249. '.hh': 'text/x-c++hdr',
  250. '.hlp': 'application/winhlp',
  251. '.hp': 'text/x-c++hdr',
  252. '.hpgl': 'application/vnd.hp-hpgl',
  253. '.hpp': 'text/x-c++hdr',
  254. '.hs': 'text/x-haskell',
  255. '.htm': 'text/html',
  256. '.html': 'text/html',
  257. '.hwp': 'application/x-hwp',
  258. '.hwt': 'application/x-hwt',
  259. '.hxx': 'text/x-c++hdr',
  260. '.ica': 'application/x-ica',
  261. '.icb': 'image/x-tga',
  262. '.icc': 'application/vnd.iccprofile',
  263. '.icm': 'application/vnd.iccprofile',
  264. '.icns': 'image/x-icns',
  265. '.ico': 'image/vnd.microsoft.icon',
  266. '.ics': 'text/calendar',
  267. '.idl': 'text/x-idl',
  268. '.ief': 'image/ief',
  269. '.iff': 'image/x-ilbm',
  270. '.ilbm': 'image/x-ilbm',
  271. '.ime': 'text/x-imelody',
  272. '.imy': 'text/x-imelody',
  273. '.ins': 'text/x-tex',
  274. '.iptables': 'text/x-iptables',
  275. '.iso': 'application/x-cd-image',
  276. '.iso9660': 'application/x-cd-image',
  277. '.it': 'audio/x-it',
  278. '.it87': 'application/x-it87',
  279. '.j2k': 'image/jp2',
  280. '.jad': 'text/vnd.sun.j2me.app-descriptor',
  281. '.jar': 'application/x-java-archive',
  282. '.java': 'text/x-java',
  283. '.jceks': 'application/x-java-jce-keystore',
  284. '.jks': 'application/x-java-keystore',
  285. '.jng': 'image/x-jng',
  286. '.jnlp': 'application/x-java-jnlp-file',
  287. '.jp2': 'image/jp2',
  288. '.jpc': 'image/jp2',
  289. '.jpe': 'image/jpeg',
  290. '.jpeg': 'image/jpeg',
  291. '.jpf': 'image/jp2',
  292. '.jpg': 'image/jpeg',
  293. '.jpr': 'application/x-jbuilder-project',
  294. '.jpx': 'image/jp2',
  295. '.js': 'application/javascript',
  296. '.json': 'application/json',
  297. '.jsonp': 'application/jsonp',
  298. '.k25': 'image/x-kodak-k25',
  299. '.kar': 'audio/midi',
  300. '.karbon': 'application/x-karbon',
  301. '.kdc': 'image/x-kodak-kdc',
  302. '.kdelnk': 'application/x-desktop',
  303. '.kexi': 'application/x-kexiproject-sqlite3',
  304. '.kexic': 'application/x-kexi-connectiondata',
  305. '.kexis': 'application/x-kexiproject-shortcut',
  306. '.kfo': 'application/x-kformula',
  307. '.kil': 'application/x-killustrator',
  308. '.kino': 'application/smil',
  309. '.kml': 'application/vnd.google-earth.kml+xml',
  310. '.kmz': 'application/vnd.google-earth.kmz',
  311. '.kon': 'application/x-kontour',
  312. '.kpm': 'application/x-kpovmodeler',
  313. '.kpr': 'application/x-kpresenter',
  314. '.kpt': 'application/x-kpresenter',
  315. '.kra': 'application/x-krita',
  316. '.ks': 'application/x-java-keystore',
  317. '.ksp': 'application/x-kspread',
  318. '.kud': 'application/x-kugar',
  319. '.kwd': 'application/x-kword',
  320. '.kwt': 'application/x-kword',
  321. '.la': 'application/x-shared-library-la',
  322. '.latex': 'text/x-tex',
  323. '.lbm': 'image/x-ilbm',
  324. '.ldif': 'text/x-ldif',
  325. '.lha': 'application/x-lha',
  326. '.lhs': 'text/x-literate-haskell',
  327. '.lhz': 'application/x-lhz',
  328. '.load' : 'text/html',
  329. '.log': 'text/x-log',
  330. '.lrz': 'application/x-lrzip',
  331. '.ltx': 'text/x-tex',
  332. '.lua': 'text/x-lua',
  333. '.lwo': 'image/x-lwo',
  334. '.lwob': 'image/x-lwo',
  335. '.lwp': 'application/vnd.lotus-wordpro',
  336. '.lws': 'image/x-lws',
  337. '.ly': 'text/x-lilypond',
  338. '.lyx': 'application/x-lyx',
  339. '.lz': 'application/x-lzip',
  340. '.lzh': 'application/x-lha',
  341. '.lzma': 'application/x-lzma',
  342. '.lzo': 'application/x-lzop',
  343. '.m': 'text/x-matlab',
  344. '.m15': 'audio/x-mod',
  345. '.m1u': 'video/vnd.mpegurl',
  346. '.m2t': 'video/mp2t',
  347. '.m2ts': 'video/mp2t',
  348. '.m3u': 'application/vnd.apple.mpegurl',
  349. '.m3u8': 'application/vnd.apple.mpegurl',
  350. '.m4': 'application/x-m4',
  351. '.m4a': 'audio/mp4',
  352. '.m4b': 'audio/x-m4b',
  353. '.m4u': 'video/vnd.mpegurl',
  354. '.m4v': 'video/mp4',
  355. '.mab': 'application/x-markaby',
  356. '.mak': 'text/x-makefile',
  357. '.man': 'application/x-troff-man',
  358. '.manifest': 'text/cache-manifest',
  359. '.markdown': 'text/x-markdown',
  360. '.mbox': 'application/mbox',
  361. '.md': 'text/x-markdown',
  362. '.mdb': 'application/vnd.ms-access',
  363. '.mdi': 'image/vnd.ms-modi',
  364. '.me': 'text/x-troff-me',
  365. '.med': 'audio/x-mod',
  366. '.meta4': 'application/metalink4+xml',
  367. '.metalink': 'application/metalink+xml',
  368. '.mgp': 'application/x-magicpoint',
  369. '.mht': 'application/x-mimearchive',
  370. '.mhtml': 'application/x-mimearchive',
  371. '.mid': 'audio/midi',
  372. '.midi': 'audio/midi',
  373. '.mif': 'application/x-mif',
  374. '.minipsf': 'audio/x-minipsf',
  375. '.mk': 'text/x-makefile',
  376. '.mka': 'audio/x-matroska',
  377. '.mkd': 'text/x-markdown',
  378. '.mkv': 'video/x-matroska',
  379. '.ml': 'text/x-ocaml',
  380. '.mli': 'text/x-ocaml',
  381. '.mm': 'text/x-troff-mm',
  382. '.mmf': 'application/x-smaf',
  383. '.mml': 'application/mathml+xml',
  384. '.mng': 'video/x-mng',
  385. '.mo': 'text/x-modelica',
  386. '.mo3': 'audio/x-mo3',
  387. '.mobi': 'application/x-mobipocket-ebook',
  388. '.moc': 'text/x-moc',
  389. '.mod': 'audio/x-mod',
  390. '.mof': 'text/x-mof',
  391. '.moov': 'video/quicktime',
  392. '.mov': 'video/quicktime',
  393. '.movie': 'video/x-sgi-movie',
  394. '.mp+': 'audio/x-musepack',
  395. '.mp2': 'video/mpeg',
  396. '.mp3': 'audio/mpeg',
  397. '.mp4': 'video/mp4',
  398. '.mpc': 'audio/x-musepack',
  399. '.mpe': 'video/mpeg',
  400. '.mpeg': 'video/mpeg',
  401. '.mpg': 'video/mpeg',
  402. '.mpga': 'audio/mpeg',
  403. '.mpl': 'video/mp2t',
  404. '.mpls': 'video/mp2t',
  405. '.mpp': 'audio/x-musepack',
  406. '.mrl': 'text/x-mrml',
  407. '.mrml': 'text/x-mrml',
  408. '.mrw': 'image/x-minolta-mrw',
  409. '.ms': 'text/x-troff-ms',
  410. '.msi': 'application/x-msi',
  411. '.msod': 'image/x-msod',
  412. '.msx': 'application/x-msx-rom',
  413. '.mtm': 'audio/x-mod',
  414. '.mts': 'video/mp2t',
  415. '.mup': 'text/x-mup',
  416. '.mxf': 'application/mxf',
  417. '.mxu': 'video/vnd.mpegurl',
  418. '.n64': 'application/x-n64-rom',
  419. '.nb': 'application/mathematica',
  420. '.nc': 'application/x-netcdf',
  421. '.nds': 'application/x-nintendo-ds-rom',
  422. '.nef': 'image/x-nikon-nef',
  423. '.nes': 'application/x-nes-rom',
  424. '.nfo': 'text/x-nfo',
  425. '.not': 'text/x-mup',
  426. '.nsc': 'application/x-netshow-channel',
  427. '.nsv': 'video/x-nsv',
  428. '.nzb': 'application/x-nzb',
  429. '.o': 'application/x-object',
  430. '.obj': 'application/x-tgif',
  431. '.ocl': 'text/x-ocl',
  432. '.oda': 'application/oda',
  433. '.odb': 'application/vnd.oasis.opendocument.database',
  434. '.odc': 'application/vnd.oasis.opendocument.chart',
  435. '.odf': 'application/vnd.oasis.opendocument.formula',
  436. '.odg': 'application/vnd.oasis.opendocument.graphics',
  437. '.odi': 'application/vnd.oasis.opendocument.image',
  438. '.odm': 'application/vnd.oasis.opendocument.text-master',
  439. '.odp': 'application/vnd.oasis.opendocument.presentation',
  440. '.ods': 'application/vnd.oasis.opendocument.spreadsheet',
  441. '.odt': 'application/vnd.oasis.opendocument.text',
  442. '.oga': 'audio/ogg',
  443. '.ogg': 'application/ogg',
  444. '.ogm': 'video/x-ogm+ogg',
  445. '.ogv': 'video/ogg',
  446. '.ogx': 'application/ogg',
  447. '.old': 'application/x-trash',
  448. '.oleo': 'application/x-oleo',
  449. '.ooc': 'text/x-ooc',
  450. '.opml': 'text/x-opml+xml',
  451. '.oprc': 'application/vnd.palm',
  452. '.ora': 'image/openraster',
  453. '.orf': 'image/x-olympus-orf',
  454. '.otc': 'application/vnd.oasis.opendocument.chart-template',
  455. '.otf': 'application/x-font-otf',
  456. '.otg': 'application/vnd.oasis.opendocument.graphics-template',
  457. '.oth': 'application/vnd.oasis.opendocument.text-web',
  458. '.otp': 'application/vnd.oasis.opendocument.presentation-template',
  459. '.ots': 'application/vnd.oasis.opendocument.spreadsheet-template',
  460. '.ott': 'application/vnd.oasis.opendocument.text-template',
  461. '.owl': 'application/rdf+xml',
  462. '.oxps': 'application/oxps',
  463. '.oxt': 'application/vnd.openofficeorg.extension',
  464. '.p': 'text/x-pascal',
  465. '.p10': 'application/pkcs10',
  466. '.p12': 'application/x-pkcs12',
  467. '.p7b': 'application/x-pkcs7-certificates',
  468. '.p7c': 'application/pkcs7-mime',
  469. '.p7m': 'application/pkcs7-mime',
  470. '.p7s': 'application/pkcs7-signature',
  471. '.p8': 'application/pkcs8',
  472. '.pack': 'application/x-java-pack200',
  473. '.pak': 'application/x-pak',
  474. '.par2': 'application/x-par2',
  475. '.pas': 'text/x-pascal',
  476. '.patch': 'text/x-patch',
  477. '.pbm': 'image/x-portable-bitmap',
  478. '.pcap': 'application/vnd.tcpdump.pcap',
  479. '.pcd': 'image/x-photo-cd',
  480. '.pcf': 'application/x-cisco-vpn-settings',
  481. '.pcf.gz': 'application/x-font-pcf',
  482. '.pcf.z': 'application/x-font-pcf',
  483. '.pcl': 'application/vnd.hp-pcl',
  484. '.pct': 'image/x-pict',
  485. '.pcx': 'image/x-pcx',
  486. '.pdb': 'chemical/x-pdb',
  487. '.pdc': 'application/x-aportisdoc',
  488. '.pdf': 'application/pdf',
  489. '.pdf.bz2': 'application/x-bzpdf',
  490. '.pdf.gz': 'application/x-gzpdf',
  491. '.pdf.xz': 'application/x-xzpdf',
  492. '.pef': 'image/x-pentax-pef',
  493. '.pem': 'application/x-x509-ca-cert',
  494. '.perl': 'application/x-perl',
  495. '.pfa': 'application/x-font-type1',
  496. '.pfb': 'application/x-font-type1',
  497. '.pfx': 'application/x-pkcs12',
  498. '.pgm': 'image/x-portable-graymap',
  499. '.pgn': 'application/x-chess-pgn',
  500. '.pgp': 'application/pgp-encrypted',
  501. '.php': 'application/x-php',
  502. '.php3': 'application/x-php',
  503. '.php4': 'application/x-php',
  504. '.php5': 'application/x-php',
  505. '.phps': 'application/x-php',
  506. '.pict': 'image/x-pict',
  507. '.pict1': 'image/x-pict',
  508. '.pict2': 'image/x-pict',
  509. '.pk': 'application/x-tex-pk',
  510. '.pkipath': 'application/pkix-pkipath',
  511. '.pkr': 'application/pgp-keys',
  512. '.pl': 'application/x-perl',
  513. '.pla': 'audio/x-iriver-pla',
  514. '.pln': 'application/x-planperfect',
  515. '.pls': 'audio/x-scpls',
  516. '.pm': 'application/x-perl',
  517. '.png': 'image/png',
  518. '.pnm': 'image/x-portable-anymap',
  519. '.pntg': 'image/x-macpaint',
  520. '.po': 'text/x-gettext-translation',
  521. '.por': 'application/x-spss-por',
  522. '.pot': 'text/x-gettext-translation-template',
  523. '.potm': 'application/vnd.ms-powerpoint.template.macroenabled.12',
  524. '.potx': 'application/vnd.openxmlformats-officedocument.presentationml.template',
  525. '.ppam': 'application/vnd.ms-powerpoint.addin.macroenabled.12',
  526. '.ppm': 'image/x-portable-pixmap',
  527. '.pps': 'application/vnd.ms-powerpoint',
  528. '.ppsm': 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
  529. '.ppsx': 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
  530. '.ppt': 'application/vnd.ms-powerpoint',
  531. '.pptm': 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
  532. '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  533. '.ppz': 'application/vnd.ms-powerpoint',
  534. '.pqa': 'application/vnd.palm',
  535. '.prc': 'application/vnd.palm',
  536. '.ps': 'application/postscript',
  537. '.ps.bz2': 'application/x-bzpostscript',
  538. '.ps.gz': 'application/x-gzpostscript',
  539. '.psd': 'image/vnd.adobe.photoshop',
  540. '.psf': 'audio/x-psf',
  541. '.psf.gz': 'application/x-gz-font-linux-psf',
  542. '.psflib': 'audio/x-psflib',
  543. '.psid': 'audio/prs.sid',
  544. '.psw': 'application/x-pocket-word',
  545. '.pw': 'application/x-pw',
  546. '.py': 'text/x-python',
  547. '.pyc': 'application/x-python-bytecode',
  548. '.pickle': 'application/python-pickle',
  549. '.pyo': 'application/x-python-bytecode',
  550. '.qif': 'image/x-quicktime',
  551. '.qml': 'text/x-qml',
  552. '.qt': 'video/quicktime',
  553. '.qti': 'application/x-qtiplot',
  554. '.qti.gz': 'application/x-qtiplot',
  555. '.qtif': 'image/x-quicktime',
  556. '.qtl': 'application/x-quicktime-media-link',
  557. '.qtvr': 'video/quicktime',
  558. '.ra': 'audio/vnd.rn-realaudio',
  559. '.raf': 'image/x-fuji-raf',
  560. '.ram': 'application/ram',
  561. '.rar': 'application/x-rar',
  562. '.ras': 'image/x-cmu-raster',
  563. '.raw': 'image/x-panasonic-raw',
  564. '.rax': 'audio/vnd.rn-realaudio',
  565. '.rb': 'application/x-ruby',
  566. '.rdf': 'application/rdf+xml',
  567. '.rdfs': 'application/rdf+xml',
  568. '.reg': 'text/x-ms-regedit',
  569. '.rej': 'text/x-reject',
  570. '.rgb': 'image/x-rgb',
  571. '.rle': 'image/rle',
  572. '.rm': 'application/vnd.rn-realmedia',
  573. '.rmj': 'application/vnd.rn-realmedia',
  574. '.rmm': 'application/vnd.rn-realmedia',
  575. '.rms': 'application/vnd.rn-realmedia',
  576. '.rmvb': 'application/vnd.rn-realmedia',
  577. '.rmx': 'application/vnd.rn-realmedia',
  578. '.rnc': 'application/relax-ng-compact-syntax',
  579. '.rng': 'application/xml',
  580. '.roff': 'text/troff',
  581. '.rp': 'image/vnd.rn-realpix',
  582. '.rpm': 'application/x-rpm',
  583. '.rss': 'application/rss+xml',
  584. '.rt': 'text/vnd.rn-realtext',
  585. '.rtf': 'application/rtf',
  586. '.rtx': 'text/richtext',
  587. '.rv': 'video/vnd.rn-realvideo',
  588. '.rvx': 'video/vnd.rn-realvideo',
  589. '.rw2': 'image/x-panasonic-raw2',
  590. '.s3m': 'audio/x-s3m',
  591. '.sam': 'application/x-amipro',
  592. '.sami': 'application/x-sami',
  593. '.sav': 'application/x-spss-sav',
  594. '.scala': 'text/x-scala',
  595. '.scm': 'text/x-scheme',
  596. '.sda': 'application/vnd.stardivision.draw',
  597. '.sdc': 'application/vnd.stardivision.calc',
  598. '.sdd': 'application/vnd.stardivision.impress',
  599. '.sdp': 'application/sdp',
  600. '.sds': 'application/vnd.stardivision.chart',
  601. '.sdw': 'application/vnd.stardivision.writer',
  602. '.sgf': 'application/x-go-sgf',
  603. '.sgi': 'image/x-sgi',
  604. '.sgl': 'application/vnd.stardivision.writer',
  605. '.sgm': 'text/sgml',
  606. '.sgml': 'text/sgml',
  607. '.sh': 'application/x-shellscript',
  608. '.shape': 'application/x-dia-shape',
  609. '.shar': 'application/x-shar',
  610. '.shn': 'application/x-shorten',
  611. '.siag': 'application/x-siag',
  612. '.sid': 'audio/prs.sid',
  613. '.sik': 'application/x-trash',
  614. '.sis': 'application/vnd.symbian.install',
  615. '.sisx': 'x-epoc/x-sisx-app',
  616. '.sit': 'application/x-stuffit',
  617. '.siv': 'application/sieve',
  618. '.sk': 'image/x-skencil',
  619. '.sk1': 'image/x-skencil',
  620. '.skr': 'application/pgp-keys',
  621. '.sldm': 'application/vnd.ms-powerpoint.slide.macroenabled.12',
  622. '.sldx': 'application/vnd.openxmlformats-officedocument.presentationml.slide',
  623. '.slk': 'text/spreadsheet',
  624. '.smaf': 'application/x-smaf',
  625. '.smc': 'application/x-snes-rom',
  626. '.smd': 'application/vnd.stardivision.mail',
  627. '.smf': 'application/vnd.stardivision.math',
  628. '.smi': 'application/x-sami',
  629. '.smil': 'application/smil',
  630. '.sml': 'application/smil',
  631. '.sms': 'application/x-sms-rom',
  632. '.snd': 'audio/basic',
  633. '.so': 'application/x-sharedlib',
  634. '.spc': 'application/x-pkcs7-certificates',
  635. '.spd': 'application/x-font-speedo',
  636. '.spec': 'text/x-rpm-spec',
  637. '.spl': 'application/x-shockwave-flash',
  638. '.spm': 'application/x-source-rpm',
  639. '.spx': 'audio/x-speex',
  640. '.sql': 'text/x-sql',
  641. '.sr2': 'image/x-sony-sr2',
  642. '.src': 'application/x-wais-source',
  643. '.src.rpm': 'application/x-source-rpm',
  644. '.srf': 'image/x-sony-srf',
  645. '.srt': 'application/x-subrip',
  646. '.ss': 'text/x-scheme',
  647. '.ssa': 'text/x-ssa',
  648. '.stc': 'application/vnd.sun.xml.calc.template',
  649. '.std': 'application/vnd.sun.xml.draw.template',
  650. '.sti': 'application/vnd.sun.xml.impress.template',
  651. '.stm': 'audio/x-stm',
  652. '.stw': 'application/vnd.sun.xml.writer.template',
  653. '.sty': 'text/x-tex',
  654. '.sub': 'text/x-subviewer',
  655. '.sun': 'image/x-sun-raster',
  656. '.sv': 'text/x-svsrc',
  657. '.sv4cpio': 'application/x-sv4cpio',
  658. '.sv4crc': 'application/x-sv4crc',
  659. '.svg': 'image/svg+xml',
  660. '.svgz': 'image/svg+xml-compressed',
  661. '.svh': 'text/x-svhdr',
  662. '.swf': 'application/x-shockwave-flash',
  663. '.swm': 'application/x-ms-wim',
  664. '.sxc': 'application/vnd.sun.xml.calc',
  665. '.sxd': 'application/vnd.sun.xml.draw',
  666. '.sxg': 'application/vnd.sun.xml.writer.global',
  667. '.sxi': 'application/vnd.sun.xml.impress',
  668. '.sxm': 'application/vnd.sun.xml.math',
  669. '.sxw': 'application/vnd.sun.xml.writer',
  670. '.sylk': 'text/spreadsheet',
  671. '.t': 'text/troff',
  672. '.t2t': 'text/x-txt2tags',
  673. '.tar': 'application/x-tar',
  674. '.tar.bz': 'application/x-bzip-compressed-tar',
  675. '.tar.bz2': 'application/x-bzip-compressed-tar',
  676. '.tar.gz': 'application/x-compressed-tar',
  677. '.tar.lrz': 'application/x-lrzip-compressed-tar',
  678. '.tar.lzma': 'application/x-lzma-compressed-tar',
  679. '.tar.lzo': 'application/x-tzo',
  680. '.tar.xz': 'application/x-xz-compressed-tar',
  681. '.tar.z': 'application/x-tarz',
  682. '.taz': 'application/x-tarz',
  683. '.tb2': 'application/x-bzip-compressed-tar',
  684. '.tbz': 'application/x-bzip-compressed-tar',
  685. '.tbz2': 'application/x-bzip-compressed-tar',
  686. '.tcl': 'text/x-tcl',
  687. '.tex': 'text/x-tex',
  688. '.texi': 'text/x-texinfo',
  689. '.texinfo': 'text/x-texinfo',
  690. '.tga': 'image/x-tga',
  691. '.tgz': 'application/x-compressed-tar',
  692. '.theme': 'application/x-theme',
  693. '.themepack': 'application/x-windows-themepack',
  694. '.tif': 'image/tiff',
  695. '.tiff': 'image/tiff',
  696. '.tk': 'text/x-tcl',
  697. '.tlrz': 'application/x-lrzip-compressed-tar',
  698. '.tlz': 'application/x-lzma-compressed-tar',
  699. '.tnef': 'application/vnd.ms-tnef',
  700. '.tnf': 'application/vnd.ms-tnef',
  701. '.toc': 'application/x-cdrdao-toc',
  702. '.torrent': 'application/x-bittorrent',
  703. '.tpic': 'image/x-tga',
  704. '.tr': 'text/troff',
  705. '.ts': 'video/mp2t',
  706. '.tsv': 'text/tab-separated-values',
  707. '.tta': 'audio/x-tta',
  708. '.ttc': 'application/x-font-ttf',
  709. '.ttf': 'application/x-font-ttf',
  710. '.ttx': 'application/x-font-ttx',
  711. '.txt': 'text/plain',
  712. '.txz': 'application/x-xz-compressed-tar',
  713. '.tzo': 'application/x-tzo',
  714. '.ufraw': 'application/x-ufraw',
  715. '.ui': 'application/x-gtk-builder',
  716. '.uil': 'text/x-uil',
  717. '.ult': 'audio/x-mod',
  718. '.uni': 'audio/x-mod',
  719. '.url': 'application/x-mswinurl',
  720. '.ustar': 'application/x-ustar',
  721. '.uue': 'text/x-uuencode',
  722. '.v': 'text/x-verilog',
  723. '.vala': 'text/x-vala',
  724. '.vapi': 'text/x-vala',
  725. '.vcard': 'text/vcard',
  726. '.vcf': 'text/vcard',
  727. '.vcs': 'text/calendar',
  728. '.vct': 'text/vcard',
  729. '.vda': 'image/x-tga',
  730. '.vhd': 'text/x-vhdl',
  731. '.vhdl': 'text/x-vhdl',
  732. '.viv': 'video/vivo',
  733. '.vivo': 'video/vivo',
  734. '.vlc': 'audio/x-mpegurl',
  735. '.vob': 'video/mpeg',
  736. '.voc': 'audio/x-voc',
  737. '.vor': 'application/vnd.stardivision.writer',
  738. '.vrm': 'model/vrml',
  739. '.vrml': 'model/vrml',
  740. '.vsd': 'application/vnd.visio',
  741. '.vss': 'application/vnd.visio',
  742. '.vst': 'image/x-tga',
  743. '.vsw': 'application/vnd.visio',
  744. '.vtt': 'text/vtt',
  745. '.w2p': 'application/w2p',
  746. '.wav': 'audio/x-wav',
  747. '.wax': 'audio/x-ms-asx',
  748. '.wb1': 'application/x-quattropro',
  749. '.wb2': 'application/x-quattropro',
  750. '.wb3': 'application/x-quattropro',
  751. '.wbmp': 'image/vnd.wap.wbmp',
  752. '.wcm': 'application/vnd.ms-works',
  753. '.wdb': 'application/vnd.ms-works',
  754. '.webm': 'video/webm',
  755. '.wim': 'application/x-ms-wim',
  756. '.wk1': 'application/vnd.lotus-1-2-3',
  757. '.wk3': 'application/vnd.lotus-1-2-3',
  758. '.wk4': 'application/vnd.lotus-1-2-3',
  759. '.wks': 'application/vnd.ms-works',
  760. '.wma': 'audio/x-ms-wma',
  761. '.wmf': 'image/x-wmf',
  762. '.wml': 'text/vnd.wap.wml',
  763. '.wmls': 'text/vnd.wap.wmlscript',
  764. '.wmv': 'video/x-ms-wmv',
  765. '.wmx': 'audio/x-ms-asx',
  766. '.woff': 'application/font-woff',
  767. '.wp': 'application/vnd.wordperfect',
  768. '.wp4': 'application/vnd.wordperfect',
  769. '.wp5': 'application/vnd.wordperfect',
  770. '.wp6': 'application/vnd.wordperfect',
  771. '.wpd': 'application/vnd.wordperfect',
  772. '.wpg': 'application/x-wpg',
  773. '.wpl': 'application/vnd.ms-wpl',
  774. '.wpp': 'application/vnd.wordperfect',
  775. '.wps': 'application/vnd.ms-works',
  776. '.wri': 'application/x-mswrite',
  777. '.wrl': 'model/vrml',
  778. '.wsgi': 'text/x-python',
  779. '.wv': 'audio/x-wavpack',
  780. '.wvc': 'audio/x-wavpack-correction',
  781. '.wvp': 'audio/x-wavpack',
  782. '.wvx': 'audio/x-ms-asx',
  783. '.wwf': 'application/x-wwf',
  784. '.x3f': 'image/x-sigma-x3f',
  785. '.xac': 'application/x-gnucash',
  786. '.xbel': 'application/x-xbel',
  787. '.xbl': 'application/xml',
  788. '.xbm': 'image/x-xbitmap',
  789. '.xcf': 'image/x-xcf',
  790. '.xcf.bz2': 'image/x-compressed-xcf',
  791. '.xcf.gz': 'image/x-compressed-xcf',
  792. '.xhtml': 'application/xhtml+xml',
  793. '.xi': 'audio/x-xi',
  794. '.xla': 'application/vnd.ms-excel',
  795. '.xlam': 'application/vnd.ms-excel.addin.macroenabled.12',
  796. '.xlc': 'application/vnd.ms-excel',
  797. '.xld': 'application/vnd.ms-excel',
  798. '.xlf': 'application/x-xliff',
  799. '.xliff': 'application/x-xliff',
  800. '.xll': 'application/vnd.ms-excel',
  801. '.xlm': 'application/vnd.ms-excel',
  802. '.xlr': 'application/vnd.ms-works',
  803. '.xls': 'application/vnd.ms-excel',
  804. '.xlsb': 'application/vnd.ms-excel.sheet.binary.macroenabled.12',
  805. '.xlsm': 'application/vnd.ms-excel.sheet.macroenabled.12',
  806. '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  807. '.xlt': 'application/vnd.ms-excel',
  808. '.xltm': 'application/vnd.ms-excel.template.macroenabled.12',
  809. '.xltx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
  810. '.xlw': 'application/vnd.ms-excel',
  811. '.xm': 'audio/x-xm',
  812. '.xmf': 'audio/x-xmf',
  813. '.xmi': 'text/x-xmi',
  814. '.xml': 'application/xml',
  815. '.xpi': 'application/x-xpinstall',
  816. '.xpm': 'image/x-xpixmap',
  817. '.xps': 'application/oxps',
  818. '.xsd': 'application/xml',
  819. '.xsl': 'application/xslt+xml',
  820. '.xslfo': 'text/x-xslfo',
  821. '.xslm' : 'application/vnd.ms-excel.sheet.macroEnabled.12',
  822. '.xslt': 'application/xslt+xml',
  823. '.xspf': 'application/xspf+xml',
  824. '.xul': 'application/vnd.mozilla.xul+xml',
  825. '.xwd': 'image/x-xwindowdump',
  826. '.xyz': 'chemical/x-pdb',
  827. '.xz': 'application/x-xz',
  828. '.yaml': 'application/x-yaml',
  829. '.yml': 'application/x-yaml',
  830. '.z': 'application/x-compress',
  831. '.zabw': 'application/x-abiword',
  832. '.zip': 'application/zip',
  833. '.zoo': 'application/x-zoo',
  834. }
  835. def contenttype(filename, default='text/plain'):
  836. """
  837. Returns the Content-Type string matching extension of the given filename.
  838. """
  839. filename=to_native(filename)
  840. i = filename.rfind('.')
  841. if i >= 0:
  842. default = CONTENT_TYPE.get(filename[i:].lower(), default)
  843. j = filename.rfind('.', 0, i)
  844. if j >= 0:
  845. default = CONTENT_TYPE.get(filename[j:].lower(), default)
  846. if default.startswith('text/'):
  847. default += '; charset=utf-8'
  848. return default