Display sensor data on webpage and oled display at the same time #9409
-
Hi,
I have tried putting the oled and webpage display functions in separate while loops with the use of different threads as described here by Andreas Spiess: Any ideas if what I am trying to achieve is possible? (Bad) code attached Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yes, that's right. Because the "accept" function will block, the rest of your code won't run. The best way to do what you want is with asyncio, and have separate tasks for the OLED, sensors, and web server. I recommend using a HTTP server library that takes care of all this for you -- e.g. https://github.com/miguelgrinberg/microdot |
Beta Was this translation helpful? Give feedback.
Yes, that's right. Because the "accept" function will block, the rest of your code won't run.
The best way to do what you want is with asyncio, and have separate tasks for the OLED, sensors, and web server.
I recommend using a HTTP server library that takes care of all this for you -- e.g. https://github.com/miguelgrinberg/microdot