1var python_process;
2
3router.get('/start_python', function(req, res) {
4 var PythonShell = require('python-shell');
5 var pyshell = new PythonShell('general.py');
6
7 pyshell.end(function (err) {
8 if (err) {
9 console.log(err);
10 }
11 });
12 python_process = pyshell.childProcess;
13
14 res.send('Started.');
15});
16
17// this stops the process
18router.get('/stop_python', function(req, res) {
19 python_process.kill('SIGINT');
20 res.send('Stopped');
21});