So I call my backend.js
from my python code like this
# server is requested to start
startServer = subprocess.Popen(['node', 'backend.js'])
# startServer.wait()
if startServer.poll:
print('Server could not be started')
sys.exit()
And my backend.js
contains
app.listen(port, () => {
console.log(`Server is listening at http://localhost:${port}`);
});
How can the backend tell python that server for some reason failed to start and exit the program or server has started and now you can go ahead? I have tried waiting for the startServer to end but that just stops the python code until server is stopped. So is there a way by which the callback function in app.listen
can send information to the python code?