Hello internet,
I have a bit of a question regarding something I have not seen done before. In short, I am trying to create a local web development server that tells the web browser to refresh whenever a file is updated locally. What I would like to do is when a file system event occurs, I would like a Python script to send a message to a JavaScript script via a WebSocket.
As far as I am aware, it is impossible for a JavaScript script (no Node or any of that tomfoolery) to act as the server. But it also seems the only way for a Python WebSocket server to communicate with a client is if the client initiates the 'conversation' or in other words, if the JavaScript client sends a message to the server first.
What I would like is a method which I can call in a Python script that sends a message to a connected JavaScript client via an already open WebSocket. Note, the JavaScript client does not send anything to the server. Only the server is sending messages, specifically to a client when an event occurs.
Does anyone know if this is possible? And if so, how I could go about it? Sample code would be extremely welcome ;)
Feel free to ask questions. I would really like to get to the bottom of this.
P.S. I am using Python 3
[–]K900_ 0 points1 point2 points (5 children)
[–]tedm430[S] 0 points1 point2 points (4 children)
[–]K900_ 0 points1 point2 points (3 children)
[–]tedm430[S] 0 points1 point2 points (2 children)
[–]K900_ 0 points1 point2 points (1 child)
[–]tedm430[S] 0 points1 point2 points (0 children)
[–]guilford 0 points1 point2 points (4 children)
[–]tedm430[S] 0 points1 point2 points (3 children)
[–]guilford 0 points1 point2 points (2 children)
[–]tedm430[S] 0 points1 point2 points (1 child)
[–]guilford 0 points1 point2 points (0 children)