我的旧代码,我使用 werkzeug run_simple 来运行应用程序。现在,我需要使用 socketio,如何将 run_simple() 更改为 socketio.run()。
我的旧代码:
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from admin import api, frontend
application = DispatcherMiddleware(frontend.create_app(), {
'/api': api.create_app()
})
if __name__ == '__main__':
run_simple('0.0.0.0', 5000, application, use_reloader=True, use_debugger=False)
我试过了:
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from flask.ext.socketio import SocketIO
from admin import api, frontend
app = frontend.create_app()
application = DispatcherMiddleware(frontend.create_app(), {
'/api': api.create_app()
})
socketio = SocketIO(app)
if __name__ == '__main__':
# run_simple('0.0.0.0', 5000, application, use_reloader=True, use_debugger=False)
socketio.run(app, host='0.0.0.0', port=5000, use_reloader=True, use_debugger=False)
但它没有用。谁能帮帮我!