I am a newbie to python. I am working on a web app and trying to call a python script from a js script. I am using ajax to call the .py script as follows but I just keep getting the code returned in the response. For simplicity, I have reduced the computation in the python script - even the variable x is not being returned to the js file.
in js function
return $.ajax({
type: 'GET',
url: 'test.py',
success: function(response) {
console.log(response);
},
error: function(response) {
return console.error(response);
}
});
test.py
#!/usr/bin/python
print("Hello World")
x = 2
return x
The request succeeds because it moves inside success. response is the python code instead of 2. Thanks for your help!