[Twisted-web] twisted web and css files

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon Nov 26 08:51:55 EST 2012

On 12:39 pm, johnaherne at rocs.co.uk wrote:
>I seem to have a problem processing css files with twisted.web using
>twisted templates.
>I get a message in my Firefox error console saying that it could not 
>the css file since the type was text/html not text/css

It sounds like the css is being served with a "Content-Type: text/html" 
header instead of a "Content-Type: text/css" header.  You should double 
check this using another tool (eg HEAD(1) or telnet(1)).  If this is the 
case, then you may need to add css to your site-wide mime.types file 
(sounds gross, I know, sorry) or add the necessary item to the mapping 
loaded by Twisted Web.

See `twisted.web.static.File.contentTypes`.  If it does not have an 
entry for css, or has the wrong content-type for it, that's the problem. 
Since you mention running on Windows, I think this is a likely 
explanation; it wouldn't surprise me if Windows didn't include a very 
complete mime types database (or one at all, or Twisted Web doesn't know 
how to load it).


More information about the Twisted-web mailing list