我开始学习樱桃,但我遇到了障碍.我无法获取静态文件来挽救我的生命.我得到了404. The path '/static' was not found.我已经google了,但还没有找到解决方案.我想要做的就是在http:// localhost:8080/static提供文件
Suggetions?
import os
import cherrypy
class Root(object):
@cherrypy.expose
def index(self):
pass
config = {
'/static':{
'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(os.path.dirname(__file__), 'static')
}
}
cherrypy.tree.mount(Root(), '/', config = config)
cherrypy.engine.start()
Run Code Online (Sandbox Code Playgroud)
一些想法:
tools.staticdir.debug = True,结合log.screen = True或其他一些更优选的日志记录设置.这将有助于我在这个答案中猜到的任何东西.tools.staticdir.dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'static')); 它必须是绝对的(或者,如果.dir不是绝对的,那么tools.staticdir.root需要).| 归档时间: |
|
| 查看次数: |
5288 次 |
| 最近记录: |