Help with persisting non-user specific data

I am trying to build a demo web application to show the real time results of an IoT sensor. I would like to be able to give my audience a URL which they can all type into their laptops / phones, and then see the real time data from the sensor. I am comfortable with the sensor side code and able to build a http POST or GET to the server. I have also implemented some basic tutorials getting real time connection between the server and client (using server side events).

My plan was that the client side of this app would open an EventListener to the server. On the server this would then make use of an SQL event (npm mysql-event) to refresh data whenever the database changed. But I am not sure how to get data from the POST (or GET) into the same global database - it seems that the default is that every client is seeing a different database. Is that right, or am I missing something ? thanks for any help ! Stephen

Hello, @sjdevlin! Welcome to the Glitch forum!

If your main goal is to show data from an IoT sensor on a web page in real-time then this diagram bellow may help/give an idea.

However, if you want to store the data to a database Iā€™d recommend loading up the database at the start of your project then having the server/http connect to that database. Note: storing the values in a database may eat up storage/disk space quickly.

Thank you for taking the time to reply ! I am that proficient with server side logic so was unsure to use sockets or server side events. I thought SSE might be easier. But will look into doing this with sockets. Thank you !

1 Like