1
我有這樣的文件夾結構:的CherryPy :::無法加載的index.html
index.html
tutorial -> public -> css -> style.css
tut.py
其中tutorial
是根。
內部tut.py
,我運行作爲python tut.py
, 這個片段集根(教程):
if __name__ == '__main__':
conf = {
'/': {
'tools.sessions.on': True,
'tools.staticdir.root': os.path.abspath(os.getcwd())
和這個映射static
內容到公共:
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': './public'
}
也代碼提供index.html
通過這個:
class StringGenerator(object):
@cherrypy.expose
def index(self):
return open('index.html')
裏面的index.html:
<link href="/static/css/style.css" rel="stylesheet">
但是當我運行127.0.0.1
,html
沒有被服務。哪裏不對?
一切看起來不錯。你遇到了什麼錯誤? – jordeu