Reputation: 15716
I recently asked this related question: Problems serving static files favicon.ico and robots.txt in CherryPy 3.1
In my config file, I have an absolute path described. Is there a way to make it a relative path? The reason is that I'm on a team. My teammates as well as my server use different paths for the location of our code.
[/]
tools.staticdir.on = True
tools.staticdir.root = "/projects/mysite/trunk/root"
tools.staticdir.dir = ""
tools.staticfile.root = "/projects/mysite/trunk/root"
[/favicon.ico]
tools.staticfile.on = True
tools.staticfile.filename = "images/favicon.ico"
[/robots.txt]
tools.staticfile.on = True
tools.staticfile.filename = "robots.txt"
[/images]
tools.staticdir.on = True
tools.staticdir.dir = "images"
[/css]
tools.staticdir.on = True
tools.staticdir.dir = "css"
[/js]
tools.staticdir.on = True
tools.staticdir.dir = "js"
Upvotes: 2
Views: 2294
Reputation: 19
I've only started playing with Cherrypy so there may be good reasons to not do this but below is what I added to the .conf file to serve files form the static directory. Note that I'm in the directory above static when I execute the python program.
[/]
tools.staticdir.root = os.getcwd()
[/static]
tools.staticdir.on = True
tools.staticdir.dir = "static"
Upvotes: 1
Reputation: 3918
Does this work?
'tools.staticdir.root': os.path.join(os.path.abspath(os.curdir), 'trunk/root'),
Upvotes: 0