I am new to spawn and I try to get the user's input from my frontend to my Node.js and then pass it to my python sentiment analysis code. But when I try to use spawn to get access to my python, it didn't response. I very much appreciate your help. Thank you.
Here what I want to do is passing the json data from the frontend to /add function via Axio.
const router = require('express').Router();
let inputData = require('../models/inputData.model');
const spawn = require("child_process").spawn;
router.route('/add').post((req, res) => {
const sentence = req.body.sentence;
const newData = new inputData({sentence});
const pythonProcess = spawn('python3', ['C:\\Users\\70519\\PycharmProjects\\pythonProject\\pythonserver.py', newData])
pythonProcess.stdout.on('data', (data) => {
res.json('I am here!')
res.json(data.toString());
})
});
However, in my website console, I don't receive 'I am here' from res.json(). Is that mean my python code is not running?