I have python generating my stylesheets in my html4 site (random background). Now I'm wanting to convert to html5 and I'm wondering if I can use a .py file in my css link <link rel = "stylesheet" href = "main.py" />
The site is currently running completely in cgi mode.
Asked
Active
Viewed 356 times
-3
![](../../users/profiles/156681.webp)
KI4JGT
- 95
-
Have you tried it yet? – Ladadadada Jun 21 '13 at 17:58
2 Answers
1
No, you can't. Do you have any idea how CSS works?
Strike that. I got that the other way round. If the web server serves valid CSS, this is possible, of course, but it really has to go through the CGI interface (or any other Python interpreter in the non-cgi case).
However, this was possible with HTML4 as well.
Performance wise I don't see a reason to do this, though. Why not just serve a static CSS?
![](../../users/profiles/8897.webp)
Sven
- 97,248
- 13
- 177
- 225
-
beyond the tag {property:value;} thing? Not really. I've basically been using my py script to store my css and then calling it from my index.cgi file. I just figured it was given to the browser at the first of the page and any time the browser saw that particular attribute it applied it as the tag was parsed. – KI4JGT Jun 21 '13 at 17:21
-
1Does the browser care what extension a css file is? If not, as long as accessing that file from a browser results in valid CSS, I don't see why it wouldn't work. – Jason Taylor Jun 21 '13 at 17:25
1
Yes, as long as the Python source is processed by the server and CSS code is emitted. Don't forget to send the appropriate Content-Type
header.
![](../../users/profiles/7360.webp)
Ignacio Vazquez-Abrams
- 45,019
- 5
- 78
- 84