Advertisement
Guest User

Untitled

a guest
Jun 10th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. var app = require('express')();
  2. var http = require('http').Server(app);
  3. var io = require('socket.io')(http);
  4.  
  5. app.get('*', function(req, res, next){
  6. console.log(req.ip + " requesting " + req.path);
  7. if (req.url === '/') {
  8. return next();
  9. }
  10. });
  11.  
  12. app.get('/', function(req, res){
  13. res.sendfile('index.html');
  14. });
  15.  
  16. io.on('connection', function(socket){
  17. var exec = require('child_process').exec;
  18. var child = exec('temperv14 -f', function(err, stdout, stderr) {
  19. if (err) {
  20. console.log(err);
  21. } else {
  22. //console.log(stdout);
  23. io.emit('temperature', stdout + 'F');
  24. }
  25. });
  26. });
  27.  
  28. http.listen(3000, function(){
  29. console.log('listening on *:3000');
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement