我有服务的静态XML样式陪从CherryPy的web应用程序的一些动态生成的输出一些麻烦。即使我提供静态文本文件的测试用例也失败了。问题的CherryPy 3.1提供静态文件
静态文件blah.txt
是在我的应用程序根目录下的/static
目录。
在我的主网站文件(conesearch.py包含CherryPy的ConeSearch页面处理程序类):
import conesearch
cherrypy.config.update('site.config')
cherrypy.tree.mount(conesearch.ConeSearch(), "/ucac3", 'ucac3.config')
...
而在site.config
我有以下选择:
[/]
tools.staticdir.root: conesearch.current_dir
[/static]
tools.staticdir.on: True
tools.staticdir.dir: 'static'
其中current_dir = os.path.dirname(os.path.abspath(__file__))
在conesearch.py
但是,我简单的测试页面(从http://www.cherrypy.org/wiki/StaticContent直取)失败,404:
def test(self):
return """
<html>
<head>
<title>CherryPy static tutorial</title>
</head>
<body>
<a href="/static/blah.txt">Link</a>
</body>
</html>"""
test.exposed = True
它试图访问127.0.0.1:8080/static/blah.txt,其中由我估计应该是AOK。任何想法或建议?
干杯,
西蒙
没有,我依然没有欢乐。不过谢谢。仍在'blah.txt'上获得404。如果我正确理解CherryPy配置文件/文件,这应该与我在上面设置的配置文件完全相同? – 2010-03-23 22:18:54