Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sendHTMLToBrowser = require("../myCode/andrewsHelpers").sendHTMLToBrowser;
- //var execExternalCommand = require("./childProcesses").execExternalCommand;
- // import the exec function defined on the child_process module
- var exec = require('child_process').exec;
- function start(response, request) {
- console.log("Request handler 'start' was called");
- var body = '<!doctype html>'+
- '<html lang="en">'+
- '<head>'+
- '<meta charset=UTF-8" />'+
- '</head>'+
- '<body>'+
- '<p>Hello Andrew :)</p>'+
- '</body>'+
- '</html>';
- sendHTMLToBrowser(response, body);
- }
- function linecount(response, request) {
- console.log("Request handler 'linecount' was called.");
- // launch the command "cat *.js | wc -l"
- exec('cat *.js | wc -l', function(err, stdout, stderr) {
- // the command exited or the launching failed
- if (err) {
- // we had an error launching the process
- console.log('child process exited with error code', err.code);
- return;
- }
- sendHTMLToBrowser(response, stdout.toString());
- });
- }
- function executeCommand(command) {
- return result;
- }
- exports.start = start;
- exports.linecount = linecount;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement