title: Run Node.js Shell_Exec command onclick
body: <p>I'm building a home automation system in NodeJS and I want to fire some commands on my raspberry pi using the Shell_exec function in Express. How can I do this with an onclick event in JADE?</p>
  
  <p>This is my app.js in Express:</p>
  
  <pre><code>var express = require('express');
  var path = require('path');
  var favicon = require('serve-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  var shell_exec = require('shell_exec').shell_exec;
  
  var mongoose = require('mongoose');
  mongoose.Promise = global.Promise;
  mongoose.connect('mongodb://localhost:27017/homeapp');
  
  var passport = require('passport');
  var LocalStrategy = require('passport-local').Strategy;
  
  var index = require('./routes/index');
  var users = require('./routes/users');
  
  var app = express();
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  
  // uncomment after placing your favicon in /public
  app.use(favicon(path.join(__dirname, 'public/images', 'favicon-32x32.png')));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(passport.initialize());
  app.use(passport.session());
  var User = require('./models/User');
  passport.use(new LocalStrategy(User.authenticate()));
  passport.serializeUser(User.serializeUser());
  passport.deserializeUser(User.deserializeUser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.use('/', index);
  app.use('/users', users);
  
  module.exports = app;
  </code></pre>
  
  <p>And this is my index.js with the routing:</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  var auth = require('../controller/AuthController.js');
  
  router.get('/', auth.home);
  
  router.get('/login', auth.login);
  
  router.post('/login', auth.doLogin);
  
  router.get('/logout', auth.logout);
  
  module.exports = router;
  </code></pre>
  
  <p>And this is the jade file where I want the onclick event to exucute the commands:</p>
  
  <pre><code>div.btn(onclick="shell_exec");
  </code></pre>