在本地运行Tornado文档
我这周在用Facebook的Tornado框架,有时候在网络不太好的地方。因为网站的内容在代码库里,我想知道怎么在本地运行它?它是在AppEngine下吗?
第一次运行的时候我没有仔细看里面的内容,所以我就直接执行了,
python website.py
结果给了我以下信息,
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/wsgiref/handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
File "/Users/phwd/tornado/website/tornado/wsgi.py", line 90, in __call__
handler = web.Application.__call__(self, HTTPRequest(environ))
File "/Users/phwd/tornado/website/tornado/wsgi.py", line 107, in __init__
self.method = environ["REQUEST_METHOD"]
KeyError: 'REQUEST_METHOD'
Status: 500 Dude, this is whack!
Content-Type: text/plain
Content-Length: 59
哦,原来它是用wsgi.py这个文件?我试着从Google App Engine调用它,
dev_appserver.py .
它启动了首页,但当我查看主要文档时,
ERROR 2011-10-07 17:26:59,566 dev_appserver.py:3360] Error encountered reading file "/Users/phwd/tornado/website/sphinx/build/html/index.html":
[Errno 2] No such file or directory: '/Users/phwd/tornado/website/sphinx/build/html/index.html'
INFO 2011-10-07 17:26:59,574 dev_appserver.py:4247] "GET /documentation/index.html HTTP/1.1" 404
我需要用Sphinx做些什么才能让这个文档在Tornado Web服务器下本地运行吗?里面有一个conf.py文件,那不是已经设置好了吗?
怎么运行这个网站应用,使用它需要哪些必要的依赖?
2 个回答
2
在某些代码中使用了 wsgiref.handlers.CGIHandler().run(app)
,这样会出现一些问题。可以用下面的代码替换,可能就能解决这个问题。
from wsgiref.simple_server import make_server
app = tornado.wsgi.WSGIApplication(
...
)
httpd = make_server('',8000,app)
httpd.serve_forever()
1
这个代码库里没有包含文档的HTML文件。你需要在“tornado/website/”这个文件夹里运行 make
命令。
另外,确保你已经安装了mysqldb。
(不过我真搞不懂,为什么一个网页服务器的文档还需要你去运行另一个性能差得多的网页服务器才能查看。)