Skip to content

Instantly share code, notes, and snippets.

@gauravchl
Created December 17, 2017 10:30
Show Gist options
  • Save gauravchl/7e7e7e9ffe7eb30fab4692cf9beffa8c to your computer and use it in GitHub Desktop.
Save gauravchl/7e7e7e9ffe7eb30fab4692cf9beffa8c to your computer and use it in GitHub Desktop.
execute local scripts from node server
const handleRequest = (req, res) => {
console.log('new Request!')
let child = execFile('/Users/om/some-script.py', [req.body])
child.stdout.on('data', data => console.log('data: ', data))
child.on('error', (err) => console.log('error:', err))
child.on('exit', (c, s) => console.log('child exit', c, s))
res.statusCode = 200;
res.end();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment