My HTML
file looks like this:
Sum: <div id="sum">?</div>
And the corresponding JavaScript like this:
function refresh(){
//Wait for request from Amazon Gateway API, then replace 'sum' with result of
Python function
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "https://8qp45dk604.execute-api.us-east- 1.amazonaws.com/beta", true);
xhttp.send();
xhttp.addEventListener("readystatechange", processRequest, false);
function processRequest(e){
if(xhttp.readyState == 4 && xhttp.status == 200){
var response = JSON.parse(xhttp.responseText);
var a = response.a;
var b = response.b;
document.getElementById("sum").innerHTML =
resultOfPythonFunction('sum.py', 'sum', a, b);
}
}
setTimeout(refresh, 3000);
}
What should I replace the line resultOfPythonFunction('sum.py', 'sum', a, b);
with in order to modify the div
with the result of a Python sum
function?