2

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"
Community
  • 1
  • 1
101010
  • 14,866
  • 30
  • 95
  • 172
  • relative to where the starting python file lives. The Python file that loads this configuration file. – 101010 Sep 09 '11 at 18:48

2 Answers2

1

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"
Guest
  • 19
  • 2
0

Does this work?

    'tools.staticdir.root': os.path.join(os.path.abspath(os.curdir), 'trunk/root'),
nom-mon-ir
  • 3,748
  • 8
  • 26
  • 42
  • 1
    No -- because that's not using a config file. That would be specifying the config in the code. – 101010 Sep 10 '11 at 18:03
  • Seems there was a similar thread: http://stackoverflow.com/questions/2954370/cherrypy-configuration-tools-staticdir-root-problem – nom-mon-ir Sep 12 '11 at 15:02