I am trying to call and execute a python script via the following javascript code in an electronjs app
function getProgramstatus(){
const { exec } = require('child_process');
exec('python python\\getProgramstatus.py', (error, stdout, stderr) => {
});
let jsonData = require('.\\js\\programstatus.json');
let itemData = JSON.stringify(jsonData);
let programstatus = JSON.parse(itemData);
sessionStorage.setItem('programstatus check', programstatus.status);
}
The goal of the python script is to write a value at a json file.
data1={
"status": "12",
"time" : time.ctime(start)
}
json_object = json.dumps( data1, indent = 4)
with open('..\js\programstatus.json', 'w') as outfile:
outfile.write(json_object)
#print("2")
sys.exit("2")
When i execute the python script via terminal it writes at json file, but when i call it from javascript it doen't write at json file. Any ideas;