Я запускаю простой http-сервер с Node.js:
var http = require('http');
var fs = require('fs');
var index = fs.readFileSync('index.html');
var sensor = require('ds18x20');
var temp = sensor.get('sensorID');
http.createServer(function(req,res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(index);
}).listen(80);
console.log(temp);
my index.html файл:
<html>
<head>
</head>
<body>
My temperature:
//space for variable: temp
</body>
</html>
Теперь я хочу напечатать серверную переменную temp в моем файле index.html. Но я не знаю, как это сделать.
Возможно, кто-то может мне помочь в обмене переменных с сервера на клиента.