I'm running two Flask Apps on my local machine.
1) My test client website (on port 5001)
2) My API (on port 5000)
If I type 127.0.0.1:5000/search/
into my browser, I get the following:
Test Hello World
If I type 127.0.0.1:5001
into my browser I get an ordinary web page containing the following HTML code (this all looks OK):
<!DOCTYPE html>
<html>
<body>
<button type="button" onclick="loadDoc()">Request data</button>
<p id="demo">TEST</p>
<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("demo").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "127.0.0.1:5000/search/", true);
xhttp.send();
}
</script>
</body>
</html>
As you can see the HTTP request is sent to 127.0.0.1:5000/search/
which is tested and working in the browser and should return Test Hello World
but unfortunately nothing happens.
Basically, I click the "Request Data" button (see above), and absolutely nothing happens.
Any ideas why? I've been stuck on this for hours.