I'm having a devil of a time getting CherryPy to serve the necessary css file for the page returned.
My directory structure:
Application
ab.py (CherryPy application)
ab.config (CherryPy config file)
html\ (html template folder)
ab.html (html template file)
css\ (css folder)
ab.css (css file)
The link statement in ab.html:
<link href="/css/ab.css" rel="stylesheet" type="text/css" />
And finally, ab.config
[/]
tools.staticdir.root = "/"
[/css/ab.css]
tools.staticfile.on = True
tools.staticfile.filename = "/css/ab.css"
My template is loaded and rendered to the browser as I expected, but no styling is applied. If I change the template to use a relative address (../css/ab.css) and open the template as a file in the browser, the styling is applied.
It took me a while to get the configuration file to a point where CherryPy did not complain about bad paths when starting the application. At this point it starts, renders, and returns fine but simply doesn't appear to serve the css file to the browser.
Any help greatly appreciated.
Update based on kind suggestions from fumanchu:
Preferring to use staticdir, and now understanding that the root refers to the filesystem absolute path, I now have this in the config file:
[/]
tools.staticdir.root = "c:/users/myaccount/documents/clientname/application"
[/css]
tools.staticdir.on = True
tools.staticdir.dir = "css"
In my HTML I have this style sheet link:
<link href="/css/ab.css" rel="stylesheet" type="text/css" />
And I'm starting CherryPy with this:
cherrypy.quickstart(ABRoot(), '/', 'ab.config')
In this configuration, I still don't get styling on my web page. When I check the page source and click on the /css/ab.css link directly, I get
NotFound: (404, "The path '/css/ab.css' was not found.")
(Note: I'm developing on a windows machine).