【发布时间】:2014-11-01 10:22:44
【问题描述】:
在使用 CherryPy 管理的 html 页面上加载我的 css 时遇到问题。 这是我的情况:
class HelloWorld(object):
@cherrypy.expose
def index(self):
return "Hello world!"
@cherrypy.expose
def sc(self):
Session = sessionmaker()
session = Session(bind=engine)
...
...
if __name__ == '__main__':
cherrypy.quickstart(HelloWorld(),config={
'/':
{'tools.staticdir.root': True,
'tools.staticdir.root': "Users/mypc/Desktop/data"},
'/css':
{ 'tools.staticdir.on':True,'tools.staticdir.dir':"/css" },
'/style.css':
{ 'tools.staticfile.on':True,
'tools.staticfile.filename':"/style.css"}
})
当我启动我的脚本时,有 wrtten:
CherryPy Checker:
dir is an absolute path, even though a root is provided.
'/css' (root + dir) is not an existing filesystem path.
section: [/css]
root: 'Users/mypc/Desktop/data'
dir: '/css'
但 root + dir 是正确的路径 (Users/mypc/Desktop/data/css) 我错在哪里以及为什么我无法通过浏览器打开我的 CSS?
提前致谢
【问题讨论】:
标签: python path cherrypy static-content