我在 flask 框架下使用 sokcetio,以下是草略架構
server.py:
from flask import Flask
from threadin import Thread
app = Flask(__name__)
socketio = SocketIO(app)
def background_thread():
while True:
...
...
@app.route('/')
def index():
thread = Thread(target=background_thread)
tread.start()
return render_template('receiver.html')
@socketio.on('connect',namespace='/test')