First time post, long time guest. Sorry if there is a specific location for this type of question, I did a pretty hardcore search for my issue I keep facing but nothing geared specifically to my issue.
I am running a PI on my local network running flask SSE server. I have it running on a private port on its local network. This private port has been port forwarded on the gateway it is connected to for a public ip > private ip. I am able access this server and see the events posting using this "http://WANUBLICIP". Now, I would like to have this SSE utilized on a shared hosting domain that I own (sockets are not an option).
First code is my PI starting the flask server
second code
Now, I have a domain with a CPanel I would like to point my Event stream client to.
just a white screen..
Admittedly I know nothing about SSE but am halfway fluent in Python so this HTML code was an example used on W3schools as I tried to understand Event Streams. There's plenty of documentation from PHP to PHP or .JS event streams but for some reason my FLASK code will not trigger an event on my domain. Here is a screenshot when I visit my web broser (WANIPUBLICPORT) which posts every second as the server responds. How can I get this to my domain instead of using the WAN address?
I am running a PI on my local network running flask SSE server. I have it running on a private port on its local network. This private port has been port forwarded on the gateway it is connected to for a public ip > private ip. I am able access this server and see the events posting using this "http://WANUBLICIP". Now, I would like to have this SSE utilized on a shared hosting domain that I own (sockets are not an option).
First code is my PI starting the flask server
second code
Code:
import sys, datetime, time, flask
app = flask.Flask(__name__)
def event_stream():
while True:
ir = 150
yield "data: " + str(ir) + " #%d @ %s\n\n"
time.sleep(1)
@app.route('/')
def stream():
return flask.Response(event_stream(), mimetype="text/event-stream")
if __name__ == "__main__":
app.run(host='0.0.0.0',port=1050)
Now, I have a domain with a CPanel I would like to point my Event stream client to.
Code:
<!DOCTYPE html>
<html>
<body>
<h1>Getting server updates</h1>
<div id="result"></div>
<script>
if(typeof(EventSource) !== "undefined") {
var source = new EventSource("WANIP:PUBLICPORT");
source.onmessage = function(event) {
document.getElementById("result").innerHTML += event.data + "<br>";
};
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support server-sent events...";
}
</script>
</body>
</html>
just a white screen..
Admittedly I know nothing about SSE but am halfway fluent in Python so this HTML code was an example used on W3schools as I tried to understand Event Streams. There's plenty of documentation from PHP to PHP or .JS event streams but for some reason my FLASK code will not trigger an event on my domain. Here is a screenshot when I visit my web broser (WANIPUBLICPORT) which posts every second as the server responds. How can I get this to my domain instead of using the WAN address?