Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
deeplook opened this issue Dec 5, 2018 · 1 comment
Open

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

deeplook opened this issue Dec 5, 2018 · 1 comment

Comments

@deeplook
Copy link
Owner

deeplook commented Dec 5, 2018

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.

@jtpio
Copy link
Collaborator

jtpio commented Dec 5, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants