I want to set up a simple Node.Js Server that should call a Python Script on running the URL. Kindly refer to the below python and Node js server files.
When I ran the server URL. The page loads! but then the server crashes and now it is giving me the following error (in the cmd prompt):
Server listening on http://localhost:8080/
this is here so we are in
events.js:141
throw er; // Unhandled 'error' event
^
Error: spawn C:UsersShubhamAnaconda3libos.py ENOENT
at exports._errnoException (util.js:837:11)
at Process.ChildProcess._handle. "theme"
return theme
else :
print("lyrics: "+lyrics)
try:
runForFun(sys.argv[0], sys.argv[1], sys.argv[2])
except IndexError:
print('Please supply arguments')
//Lets require/import the HTTP module
var http = require('http');
var PythonShell = require('python-shell');
//Let's define a port we want to listen to
const PORT=8080;
//We need a function that handles requests and sends the response
function handleRequest(request, response){
var options = {
mode: 'text',
pythonPath: 'C:\Users\Shubham\Anaconda3\lib\os.py',
pythonOptions: ['-u'],
scriptPath: 'C:\Users\Shubham\Google Drive\Capstone\Theme Extraction',
args: ['value1', 'value2', 'value3']
};
console.log("this is here so we are in");
PythonShell.run('runPython.py', options, function (err, results) {
if (err) throw err;
console.log('results: %j', results, 'finished');
});
response.end('It Works!! Path Hit: ' + request.url);
}
//Create a server
var server = http.createServer(handleRequest);
//Lets start our server
server.listen(PORT, function(){
//Callback triggered when server is successfully listening. Hurray!
console.log("Server listening on: http://localhost:%s/", PORT);
});