问题
Case 1
Suppose you have a Python Flask application and you want to socketize it - you do the standard:
app = Flask("MyApp")
socketio = SocketIO(app)
Case 2
Suppose you have a Python Flask application and you want to integrate Flask-JSGlue - https://pypi.org/project/Flask-JSGlue/ - you do the standard:
jsglue = JSGlue()
app = Flask("MyApp")
jsglue.init_app(app)
Case 3 (Question)
Suppose now you want to integrate Flask-JSGlue on a socketized app - how would you go with this?
I'm trying to understand how can I merge Case 1 and Case 2 in order to obtain a socketized Flask app that integrates Flask-JSGlue.
What I've tried
As a first try I tried doing:
jsglue = JSGlue()
app = Flask("MyApp")
socketio = SocketIO(app)
jsglue.init_app(socketio)
But this results in the following error:
jsglue.init_app(socketio) File "C:\Python27\lib\site-packages\flask_jsglue.py", line 31, in init_app @app.route(JSGLUE_JS_PATH) AttributeError: 'SocketIO' object has no attribute 'route'
As a second try, as stated also in the comments, I tried doing:
jsglue = JSGlue()
app = Flask("MyApp")
socketio = SocketIO(app)
jsglue.init_app(app)
Doing so results in program being executed but socketized functions becoming totally unresponsive.
If anybody knows how to do this, that would be great
来源:https://stackoverflow.com/questions/54310058/integrate-flask-jsglue-on-a-socketized-flask-socketio-application