Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express');
  2. var app = express();
  3. var spawn = require('child_process');
  4.  
  5.  
  6. var server = app.listen(8081, function(){
  7.     console.log('listening on port %d', server.address().port);
  8. });
  9.  
  10. app.use('/IRmanager', express.static(__dirname + '/public'));
  11.  
  12. app.get('/', function(req, res){
  13.     res.redirect('IRmanager');
  14. });
  15. app.get('/IR', function(req, res){
  16.     if (req.query.status == 'on1'){
  17.         spawn.execFile('/home/pi/Scripts/RF/RF1_ON.sh', function(error,stdout, stderr)
  18.         {
  19.             console.log(stdout);
  20.         });
  21.     }
  22.     if (req.query.status == 'off1'){
  23.         spawn.execFile('/home/pi/Scripts/RF/RF1_OFF.sh', function(error,stdout, stderr)
  24.         {
  25.             console.log(stdout);
  26.         });
  27.     }
  28.  
  29.     if (req.query.status == 'on2'){
  30.         spawn.execFile('/home/pi/Scripts/RF/RF2_ON.sh', function(error,stdout, stderr)
  31.         {
  32.             console.log(stdout);
  33.         });
  34.     }
  35.     if (req.query.status == 'off2'){
  36.         spawn.execFile('/home/pi/Scripts/RF/RF2_OFF.sh', function(error,stdout, stderr)
  37.         {
  38.             console.log(stdout);
  39.         });
  40.     }
  41.     if (req.query.status == 'on3'){
  42.         spawn.execFile('/home/pi/Scripts/RF/RF3_ON.sh', function(error,stdout, stderr)
  43.         {
  44.             console.log(stdout);
  45.         });
  46.     }
  47.     if (req.query.status == 'off3'){
  48.         spawn.execFile('/home/pi/Scripts/RF/RF3_OFF.sh', function(error,stdout, stderr)
  49.         {
  50.             console.log(stdout);
  51.         });
  52.     }
  53.     if (req.query.status == 'on4'){
  54.         spawn.execFile('/home/pi/Scripts/RF/RF4_ON.sh', function(error,stdout, stderr)
  55.         {
  56.             console.log(stdout);
  57.         });
  58.     }
  59.     if (req.query.status == 'off4'){
  60.         spawn.execFile('/home/pi/Scripts/RF/RF4_OFF.sh', function(error,stdout, stderr)
  61.         {
  62.             console.log(stdout);
  63.         });
  64.     }
  65.     if (req.query.status == 'on5'){
  66.         spawn.execFile('/home/pi/Scripts/RF/RF5_ON.sh', function(error,stdout, stderr)
  67.         {
  68.             console.log(stdout);
  69.         });
  70.     }
  71.     if (req.query.status == 'off5'){
  72.         spawn.execFile('/home/pi/Scripts/RF/RF5_OFF.sh', function(error,stdout, stderr)
  73.         {
  74.             console.log(stdout);
  75.         });
  76.     }
  77.  
  78.  
  79.  
  80.  
  81.     if (req.query.status == 'power'){
  82.         spawn.execFile('/home/pi/Scripts/BTN_1.sh', function(error,stdout, stderr)
  83.         {
  84.             console.log(stdout);
  85.         });
  86.     }
  87.     res.sendStatus(200);
  88. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement