-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to ws.send from another Flask route #19
Comments
@danohn Yes, I don't see why not. The |
Thanks @miguelgrinberg I'll try that out and share the results here |
Hi @miguelgrinberg , I'm clearly not doing something right or not understanding the code, apologies! Here is my Flask app:
What I am trying to achieve is when someone sends a POST request to /publish, I extract the message from the POST form and then I want to send that message to the JS client which has already connected to the server on the /echo route. |
By the way, with the above code, my index.html is identical to your example. |
This is partly my fault, because the example code in which you based this was confusing, in that it used the The WebSocket route now looks like this: @sock.route('/echo')
def echo(ws):
while True:
data = ws.receive()
ws.send(data) So hopefully it is now more clear what you need to do. The I mentioned this in my previous reply:
|
Thanks @miguelgrinberg , it looks like flask-socketio might be a better project for my use case. Appreciate the help :) |
Hi @miguelgrinberg , I just wanted to provide a quick update. I ended up implementing this with your Flask-SocketIO library. Here is the code I am using:
Just out of interest, would the same have been possible with Flask-Sock? |
Hi Miguel, I have a Flask route which accepts a POST request with a parameters. Given one of the parameters is 'hello', is it possible to ws.send this 'hello' string to one of the connected ws clients? My app is purely server to client messages. Thanks!
The text was updated successfully, but these errors were encountered: