I have the json data in nodejs. And I try to pass this data to python. But I can't get a reply from PythonFIle.
jsonData Format
[
{
id: 123,
option: ["A","B"],
description: "Why I can't pass this data to Python"
},
{
id: 456,
option: ["A","B"],
description: "Why I can't pass this data to Python"
},{....}
]
node.js
var { PythonShell } = require('python-shell');
let pyshell = new PythonShell('../pythonFile.py', { mode: 'json ' });
pyshell.send(jsonData)
pyshell.on('message', function (message) { //But never receive data from pythonFile.
console.log("HIHI, I am pythonFile context") //Not appear this message
console.log(message); //Not appear this message
});
pyshell.end(function (err) { // Just run it
if (err) throw err;
console.log('finished'); //appear this message
});
pythonFile.py
import json
import sys
jsJSONdata = input() //recieve js data
print(jsJSONdata) //send jsJSONdata to nodejs
Thanks for your help.