javascript - How do I modify the page I'm serving in node.js -
ok, have server.js
var express = require("express"), app = express(), bodyparser = require('body-parser'); app.use(bodyparser.urlencoded({ extended: true })); app.use(bodyparser.json()); app.use(express.static(__dirname + '/')); app.post('/message', function(req, res) { var jsondata = req.body; if (jsondata.hasownproperty('phone1')) { console.log("phone 1 connected to", jsondata.phone1.connection, "and has downlink speed of", jsondata.phone1.dl, "mbps"); } else if (jsondata.hasownproperty('phone2')) { console.log("phone 2 connected to", jsondata.phone2.connection, "and has downlink speed of", jsondata.phone2.dl, "mbps"); } }); var port = 1337; app.listen(port); console.log("running @ port " + port);
and see want stuff when server gets posted on /message. can console.log stuff yes, want change things on web page server serving. post requests coming server. server presents them.
how can without having update page?
i'm using angularjs on client side, way client side pick json data nice.
i hope present data in highcharts gauges , charts simple text update on page element (e.g. <p id="example">
) fine answer question.
i know can jquery node still lack window element manipulate presented data. nw.js might want, haven't still tried though, suspect there might solution problem.
if want push new content client (opposite flow client requesting data server), websockets option (see http://socket.io/ common library).
alternatively, setup long polling on client side. using javascript periodically 'poll' server information using setinterval
or similar approach.
Comments
Post a Comment