-
Notifications
You must be signed in to change notification settings - Fork 3
/
ml.js
41 lines (35 loc) · 1.18 KB
/
ml.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const { spawn } = require('child_process');
console.log("Python script running");
module.exports = {
start: function(dCriminal, date, callback){
const childPython = spawn('python', ['model.py', `${dCriminal}`, `${date}`]);
let result;
childPython.stdout.on('data', (data) => {
// console.log(`stdout: ${data}`);
result = `${data}`;
// console.log(result);
// return result;
});
childPython.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
// return data;
});
childPython.on('close', (code) => {
// console.log(`child process exited with code ${code}`);
return callback(result);
// return code;
});
// console.log(result);
// return result;
}
}
// const childPython = spawn('python', ['model.py', '2', '382']);
// childPython.stdout.on('data', (data) => {
// console.log(`stdout: ${data}`);
// });
// childPython.stderr.on('data', (data) => {
// console.error(`stderr: ${data}`);
// });
// childPython.on('close', (code) => {
// console.log(`child process exited with code ${code}`);
// });