import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
return "Hello, world"
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
当我写return而不是self.write时,它会给我一个错误
Traceback (most recent call last):
File "/home/nishant-un/env/local/lib/python2.7/site-packages/tornado/web.py", line 1155, in _when_complete
raise ValueError("Expected Future or None, got %r" % result)
ValueError: Expected Future or None, got 'Hello, world'
它不明白这个Values Error
究竟是什么意思
我正在使用Tornado 3.1.1
答案 0 :(得分:2)
def get(self, *args, **kwargs):
raise HTTPError(405)