Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express');
- var app = express();
- var spawn = require('child_process');
- var server = app.listen(8081, function(){
- console.log('listening on port %d', server.address().port);
- });
- app.use('/IRmanager', express.static(__dirname + '/public'));
- app.get('/', function(req, res){
- res.redirect('IRmanager');
- });
- app.get('/IR', function(req, res){
- if (req.query.status == 'on1'){
- spawn.execFile('/home/pi/Scripts/RF/RF1_ON.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'off1'){
- spawn.execFile('/home/pi/Scripts/RF/RF1_OFF.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'on2'){
- spawn.execFile('/home/pi/Scripts/RF/RF2_ON.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'off2'){
- spawn.execFile('/home/pi/Scripts/RF/RF2_OFF.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'on3'){
- spawn.execFile('/home/pi/Scripts/RF/RF3_ON.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'off3'){
- spawn.execFile('/home/pi/Scripts/RF/RF3_OFF.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'on4'){
- spawn.execFile('/home/pi/Scripts/RF/RF4_ON.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'off4'){
- spawn.execFile('/home/pi/Scripts/RF/RF4_OFF.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'on5'){
- spawn.execFile('/home/pi/Scripts/RF/RF5_ON.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'off5'){
- spawn.execFile('/home/pi/Scripts/RF/RF5_OFF.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- if (req.query.status == 'power'){
- spawn.execFile('/home/pi/Scripts/BTN_1.sh', function(error,stdout, stderr)
- {
- console.log(stdout);
- });
- }
- res.sendStatus(200);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement