express - Automatically Refresh an 'app.get()' in Node.js -
I tried to find this topic everywhere, unsuccessful.
I have an app.get () code, really simple, which receives a notification from the variable that is constantly changing ("Equus [ID] .status"), I Want to check if variables change from time to time?
Other options Keep a track on this variable, and when it changes the app again. Get () again.
My code:
I want to refresh this:
app1.get ("/", function (rick, race) {id = 1; res.render (__DERNAM + '/ Connected HM', 'Device:' Estima 1 ', Status: Equip [ID]. Stats, Historical: Equipped [ID] .hist});});
And this is what "status" changes
app1.get ("/ open", function (req, res) {id = 1 ; [Current] "time = date format (now," H: celebrity, MM: ss "); console.log (time +" - the device is connected to 'Astera 1' port 3001; res.end}); App1.get (Ric, Race) {ID = 1; Preparation [ID] .status = 'desconectado'; [ID] Equip it with .hist = equip [id] .hist + equip [id ] Status; var now = new date (); time = date format (now, "h: mm: ss"); console.log (time + "- device 'astera1' is disconnected"); res.end });
app.get ()
is a server - side code , And there is no power to change the customer-side with it. In the client-side, you need to employ JavaScript code to vote on a regular basis on the server (AJAX) or listen to the server actively for changes through these websites. In this way you either refresh the whole page You can choose to do or just load relevant changes (like this is a lot of site!).
You should consider these relevant techniques: javascript, ajax, long-polling, socket. O
Comments
Post a Comment