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 load
the css file since the type was text/html not text/css
I am running on windows 7 32bit
python 2.7.3
twisted 12.2.0
twisted templates
The template renders fine but without the styling.
I have hunted around for some ideas as to what the problem is but most seem
to be that people have not added the static file location to root.
In theory I do not have that problem since the message says it has found
the file but will not process it since it has the wrong type.
In my template file I add the link for the css file and give it the correct
file type. But I assume I have overlooked something since it refuses to
process the css.
My template is based on one of the demo templates and I have really just
added the css link
<html xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1">
<head>
<title>
Add Admin User
</title>
<link href="styles/jahstyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div t:render="header" />
<ul>
<li t:render="widgets">
On 12:39 pm, johnaherne@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 load 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). Jean-Paul
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).
Jean-Paul
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
Thanks for the info. I have checked out contentTypes and it would appear to be present {css: text/css). What I have not been able to pin down is where the content type is being set or unset or being left as html. Chrome seems to read in the css file but still does not do what I expect. Firefox still says it will not load the resource. So everyone can find it but they all say it is typed as text/html. I imagine no one else has seen this, since all the comments I see say that once they set up the static File it all starts to work. Looks like more ploughing through docs and code. Thanks John Aherne -- *John Aherne* * * * * * * *www.rocs.co.uk * 020 7223 7567
participants (2)
-
exarkun@twistedmatrix.com
-
John Aherne