Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = require('express')();
- var http = require('http').Server(app);
- var io = require('socket.io')(http);
- app.get('*', function(req, res, next){
- console.log(req.ip + " requesting " + req.path);
- if (req.url === '/') {
- return next();
- }
- });
- app.get('/', function(req, res){
- res.sendfile('index.html');
- });
- io.on('connection', function(socket){
- var exec = require('child_process').exec;
- var child = exec('temperv14 -f', function(err, stdout, stderr) {
- if (err) {
- console.log(err);
- } else {
- //console.log(stdout);
- io.emit('temperature', stdout + 'F');
- }
- });
- });
- http.listen(3000, function(){
- console.log('listening on *:3000');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement