flask-sockets

How do i properly install flask-socketIO?

流过昼夜 提交于 2021-02-08 11:15:46
问题 I have installed multiple times Flask-socketio on my mac, closely reading the instructions and installing the requirements (eventlet/gevent). Athough when i run my simple code to test, it either says that i have not imported the modules or show nothing until i open index.html in my browser where it then displays : The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO) Here is my app.py code: from

How do i properly install flask-socketIO?

冷暖自知 提交于 2021-02-08 11:14:11
问题 I have installed multiple times Flask-socketio on my mac, closely reading the instructions and installing the requirements (eventlet/gevent). Athough when i run my simple code to test, it either says that i have not imported the modules or show nothing until i open index.html in my browser where it then displays : The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO) Here is my app.py code: from

Send WebSocket message from Flask view

ⅰ亾dé卋堺 提交于 2019-12-23 03:32:16
问题 I'm trying to make a Flask app that uses WebSockets. The example from Flask-sockets works but how would I send a message from a regular view? Similarly to how Flask-SocketIO use .emit() and .send() -methods. In the example below (from the Flask-Sockets example) I would for instance like to be able to broadcast a message from the hello -view. from flask import Flask from flask_sockets import Sockets app = Flask(__name__) sockets = Sockets(app) @sockets.route('/echo') def echo_socket(ws): while

Emit websocket message from a view

a 夏天 提交于 2019-12-07 11:00:46
问题 I am playing around with websockets in order to see if I can replace polling updates to a project. I am using Flask-Sockets and I want to emit an update through a Flask view. For example from flask import Flask from flask_sockets import Sockets app = Flask(__name__) sockets = Sockets(app) @sockets.route('/echo') def echo_socket(ws): while True: message = ws.receive() ws.send(message) @app.route('/') def hello(): # here I want to emit a message like ws.send(message) return 'Hello World!' I

Send WebSocket message from Flask view

我的未来我决定 提交于 2019-12-06 15:57:56
I'm trying to make a Flask app that uses WebSockets. The example from Flask-sockets works but how would I send a message from a regular view? Similarly to how Flask-SocketIO use .emit() and .send() -methods. In the example below (from the Flask-Sockets example) I would for instance like to be able to broadcast a message from the hello -view. from flask import Flask from flask_sockets import Sockets app = Flask(__name__) sockets = Sockets(app) @sockets.route('/echo') def echo_socket(ws): while not ws.closed: message = ws.receive() ws.send(message) @app.route('/') def hello(): # How can I send a

How do I get this websocket example to work with Flask?

折月煮酒 提交于 2019-12-03 17:07:13
问题 I'm trying to use Kenneth reitz's Flask-Sockets library to write a simple websocket interface/server. Here is what I have so far. from flask import Flask from flask_sockets import Sockets app = Flask(__name__) sockets = Sockets(app) @sockets.route('/echo') def echo_socket(ws): while True: message = ws.receive() ws.send(message) @app.route('/') def hello(): return \ ''' <html> <head> <title>Admin</title> <script type="text/javascript"> var ws = new WebSocket("ws://" + location.host + "/echo");