我在使用龙卷风的StaticFileHandler
课时获得了以下追溯。
追溯:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1334, in _execute
result = yield result
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 628, in run
value = future.result()
File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 109, in result
raise_exc_info(self._exc_info)
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 175, in wrapper
yielded = next(result)
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 2110, in get
self.root, absolute_path)
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 2286, in validate_absolute_path
raise HTTPError(404)
HTTPError: HTTP 404: Not Found
这是我目录的结构:
服务器/
httpserver.py的内容:
settings = {
'debug': True,
'autoreload': True,
}
application = tornado.web.Application([\
(r"/(.*)",tornado.web.StaticFileHandler,\
{"path":"static/static/foo/bar/"}),],\
**settings)
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
我已经完成了类似的问题,他们似乎没有给我一个合适的解决方案。
答案 0 :(得分:0)
我自己解决了这个问题。我添加了一个关键字参数static_path,一个从root到.py文件所在目录的路径。修正后的工作代码:
settings = {
'debug': True,
'autoreload': True,
'static_path': '/home/path/to/pythonFile'
}
application = tornado.web.Application([\
(r"(.*)",tornado.web.StaticFileHandler,\
{"path":"static/foo/bar"}),],\
**settings)
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()