I am using Cherrypy v3.2. I fail to find good docs about how to write nice config files. At the moment here is an excerpt of what I have (the original file is fairly large) :
[global]
server.thread_pool = 8
server.socket_host = '10.109.26.56'
server.socket_port = 8000
tools.sessions.on = True
[/]
tools.staticdir.root = "C:\Documents and Settings\ginssj\Desktop\cherry"
[/img/loading_transparent.gif]
tools.staticfile.on = True
tools.staticfile.filename = "C:\Documents and Settings\ginssj\Desktop\cherry\img\loading_transparent.gif"
[/style/jquery.jgrowl.css]
tools.staticfile.on = True
tools.staticfile.filename = "C:\Documents and Settings\ginssj\Desktop\cherry\style\jquery.jgrowl.css"
[/style/iegl/Samples.css]
tools.staticfile.on = True
tools.staticfile.filename = "C:\Documents and Settings\ginssj\Desktop\cherry\style\iegl\Samples.css"
The thing is that my app has to get deployed on different machines, and I'd like to have to change the absolute root path only once. Is is possible to specify other paths as relative to the root that I specify on top ?
staticdir and staticfile are two different tools; they don't share config. If you're going to use staticfile, then set its root:
[/]
tools.staticfile.root = "C:\Documents and Settings\ginssj\Desktop\cherry"
and then you can use relative file paths for the .file
entries:
[/style/iegl/Samples.css]
tools.staticfile.on = True
tools.staticfile.filename = "style\iegl\Samples.css"
If you'd like to use staticdir to serve all the files in a single folder (like \style
) then set staticdir.root similarly.