如何使用python制作websocket服务器
展开全部
from SocketServer import ThreadingTCPServer, StreamRequestHandler
class MyStreamRequestHandler(StreamRequestHandler):
def handle(self):
while True:
# 逻辑
pass
if __name__ == "__main__":
host = ""
port = 12345
addr = (host, port)
server = ThreadingTCPServer(addr, MyStreamRequestHandler)
server.serve_forever()
在supervisor中执行这个脚本就可以了。
class MyStreamRequestHandler(StreamRequestHandler):
def handle(self):
while True:
# 逻辑
pass
if __name__ == "__main__":
host = ""
port = 12345
addr = (host, port)
server = ThreadingTCPServer(addr, MyStreamRequestHandler)
server.serve_forever()
在supervisor中执行这个脚本就可以了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询