我有服務的靜態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