开发者

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

开发者 https://www.devze.com 2023-02-10 15:39 出处:网络
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-d

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.s开发者_如何学JAVAtaticdir.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?


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.


Not sure in CherryPY, but why not configure your front end webserver to serve static files? You really don't want that traffic hitting your framework.

0

精彩评论

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