开发者

Is there a way to use relative paths while serving static files using CherryPy 3.2 with a config file?

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 r开发者_JS百科eason 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"


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"


Does this work?

    'tools.staticdir.root': os.path.join(os.path.abspath(os.curdir), 'trunk/root'),
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜