Override mimetype for .css files

This should avoid the issue several people have had with unstyled pages
on misconfigured Windows systems. I think practicality beats purity
here.

Closes gh-1350
This commit is contained in:
Thomas Kluyver 2016-04-15 21:49:32 +01:00
parent db7fa4ab85
commit cc3a8668f2

View File

@ -12,6 +12,7 @@ import importlib
import io
import json
import logging
import mimetypes
import os
import random
import re
@ -1115,7 +1116,14 @@ class NotebookApp(JupyterApp):
raise
self.log.warning("Error loading server extension %s", modulename,
exc_info=True)
def init_mime_overrides(self):
# On some Windows machines, an application has registered an incorrect
# mimetype for CSS in the registry. Tornado uses this when serving
# .css files, causing browsers to reject the stylesheet. We know the
# mimetype always needs to be text/css, so we override it here.
mimetypes.add_type('text/css', '.css')
@catch_config_error
def initialize(self, argv=None):
super(NotebookApp, self).initialize(argv)
@ -1128,6 +1136,7 @@ class NotebookApp(JupyterApp):
self.init_terminals()
self.init_signal()
self.init_server_extensions()
self.init_mime_overrides()
def cleanup_kernels(self):
"""Shutdown all kernels.