ipyrest icon indicating copy to clipboard operation
ipyrest copied to clipboard

Find and use file extension in URL in addition to MIME types

Open deeplook opened this issue 6 years ago • 1 comments

Given that many sites do not provide proper MIME types for some content, like GitHub gists, it would be useful to try extracting a "file extension" from the URL and derive a MIME type and ipyrest response view. Either using the builtin mimetypes and/or some additional mapping. Then it would be less necessary to use a separate step for post-processing the response before rendering it.

deeplook avatar Dec 05 '18 10:12 deeplook

The mimetypes module from the standard library could be worth a try:

import mimetypes
mimetypes.guess_type('https://raw.githubusercontent.com/jupyterlab/jupyterlab-demo/master/data/iris.csv')
('text/csv', None)

Not sure how well it would handle more exotic MIME types though.

jtpio avatar Dec 05 '18 16:12 jtpio