Created
December 17, 2017 10:30
-
-
Save gauravchl/7e7e7e9ffe7eb30fab4692cf9beffa8c to your computer and use it in GitHub Desktop.
execute local scripts from node server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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