【发布时间】:2023-10-25 03:20:01
【问题描述】:
我有以下基本的龙卷风应用程序:
import tornado.web
class IndexHandler(tornado.web.RequestHandler):
"""Regular HTTP handler to serve the ping page"""
def get(self):
self.write("OK")
if __name__ == "__main__":
app = tornado.web.Application([
(r"/", IndexHandler),
])
app.listen(8000)
print 'Listening on 0.0.0.0:8000'
tornado.ioloop.IOLoop.instance().start()
这将在"http://localhost:8000" 上运行。我如何让它运行并接受ws://localhost:8000 的连接?
【问题讨论】:
-
您将需要一个 websocket 服务器,并且它将具有与普通 HTTP 不同的端点。
-
@KlausD。 ——你的意思是在 Tornado 中不能完成?可以在 python 中完成的示例应用程序是什么?
-
可以在 Tornado 中完成。至少看看官方文档:tornadoweb.org/en/stable/websocket.html