Closed AlekseyFedorovich closed 2 years ago
Unfortunately I think you are looking at this from the wrong side. This library provides a communication mechanism. It will just allow you to send information from the client to the server or viceversa. The documentation is brief because this library is small.
You'll be replacing those HTTP requests you have now with WebSocket messages, but everything else will be largely the same. From what you are saying your problem is in updating a chart, which is all in the browser/javascript domain.
@AlekseyFedorovich , not sure if this may help you, I just created a small example of Flask-Sock together with HTMX for a self-updating webpage: https://github.com/paluigi/flask-htmx I guess you can add a button to request updates from the sensor, or just call to request new data in a loop. Plotly graphs could be saved as images and placed in the static folder (I haven't test image updates in the webpage, but they should work) This is a toy example, I created it because I was looking for a way to make a small real-time dashboard and I didn't find any other.
@paluigi thank you for your answer. I solved the problem with Ajax (JQuery) enabling front-end <-> back-end communication on an interval basis
Hi Miguel, I'm struggling to find the best solution to make a web page communicate (back and forth) between my laptop and a sensor.
For example I'd like this web page to have a form to set measure parameters, a button send them to the sensor asking for a new measure and a plotly graph to show measure result (updated when the measure is actually received). MicroPython is used on the sensor Micro Controller.
Could this package be the way to go? Could you help me with a toy example? (package docs are quite brief at the moment)
Currently, I was communicating through http requests but I was struggling to make the plot update when new data was posted (see this question)