Open deeplook opened 5 years ago
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.
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.