【发布时间】:2016-08-08 22:39:13
【问题描述】:
我有这个文件夹结构:
index.html
tutorial -> public -> css -> style.css
tut.py
tutorial 是根。
在tut.py 内部,我以python tut.py 运行,
这个 sn-p 设置根(教程):
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 没有得到服务。怎么了?
【问题讨论】:
-
一切看起来都很好。你遇到了什么错误?