problem running hello world with tornado web server (Python 2.5,Win 7)

左心房为你撑大大i 提交于 2019-12-30 09:42:33

问题


I am using Python 2.5 on Windows 7 (64bit).

I installed pycurl-7.15.5.1 (with win binaries) and tornado (using pip).

When I run the following hello world code:

import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello World!")

if __name__=='__main__':
    app = tornado.web.Application([(r"/",MainHandler),])
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

I get the following error:-

Traceback (most recent call last):

  File "hello_tornado.py", line 11, in <module>
    application.listen(8888)
  File "c:\Python25\Lib\site-packages\tornado\web.py", line 1193, in listen
    server.listen(port, address)
  File "c:\Python25\Lib\site-packages\tornado\netutil.py", line 100, in listen
    sockets = bind_sockets(port, address=address)
  File "c:\Python25\Lib\site-packages\tornado\netutil.py", line 263, in bind_sockets
    sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
  AttributeError: 'module' object has no attribute 'IPV6_V6ONLY'

回答1:


Tornado has some IPv6 confusion on windows apparently. You can fix it by specifiyig the IP you want it to listen on like this:

application.listen(8888,'127.0.0.1')

or maybe

application.listen(8888,'0.0.0.0')



回答2:


from tornado web page (http://www.tornadoweb.org/)

Platforms: Tornado should run on any Unix-like platform, although for the best performance and scalability only Linux and BSD (including BSD derivatives like Mac OS X) are recommended.

I think it is not compatible with windows

Things similar with tornado can be achieve with twisted framework http://twistedmatrix.com which works under windows

interesting pointers are

http://twistedmatrix.com/documents/current/web/howto/web-in-60/index.html

and

http://twistedmatrix.com/documents/current/web/howto/web-in-60/dynamic-content.html



来源:https://stackoverflow.com/questions/7503039/problem-running-hello-world-with-tornado-web-server-python-2-5-win-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!