我想使用python socket io客户端向烧瓶套接字io发送一些数据(世界),但是浏览器中什么都没有显示
这是我的客户代码
from socketIO_client import SocketIO, LoggingNamespace
def on_aaa_response(args):
print('on_aaa_response', args['data'])
socketIO = SocketIO('127.0.0.1', 5000)
socketIO.on('aaa_response', on_aaa_response)
socketIO.emit('aaa')
socketIO.wait(seconds=1)
这是我的烧瓶代码
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
@socketio.on('aaa')
def test_connect():
print("Welcome, aaa received")
emit('aaa_response', {'data': 'Server'})
@app.route('/')
def hello_world():
return 'Hello, World!'
if __name__ == '__main__':
socketio.run(app)