Search code examples
pythoncherrypy

Is there no way to serve a static directory and its children i Cherrypy?


Using Cherrypy version 3.0.2

Given a file-structure like this:

static-dir 2011 2010 2009 ...

I use the configuration: '/static': {'tools.staticdir.on': True, 'tools.staticdir.dir': 'static-dir'}

This works fine fore getting /static/anyfile

But if I try /static/2009/anyfile I get an error. I can add an entry in the configuration for this directory like: '/static/2009': {'tools.staticdir.on': True, 'tools.staticdir.dir': 'static-dir/2009'}

This works, but it there no other way to serve sub-directory’s? Do I have to enter every directory under static-dir in then configuration to serve them?


Solution

  • You shouldn't have to enter multiple entries; it should descend as far down as you need to. What error are you getting? 404? If you're using Cherrypy 3.2, try setting 'tools.staticdir.debug' to True.