I wrote the below code to invoke python code from Javascript code, i.e on press of some button, But when I run this, I get the full python file as output instead of execution of that file. Can someone guide me how to fix that.
Got a similar question here, but could not understand the solution : Triggering Python script using AJAX Javascript request on local server using vanilla JS
My code :
const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert(this.responseText);
alert("hello from js");
}
};
xhttp.open("GET", "uploadFile.py");
xhttp.send();
Can someone please help me ?
Regards