mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
25 lines
496 B
HTML
25 lines
496 B
HTML
<!DOCTYPE html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
<title>SSE example</title>
|
|
</head>
|
|
<body>
|
|
<h1>Stock Price</h1>
|
|
<script type="text/javascript">
|
|
|
|
function read_data() {
|
|
var stream = new EventSource('/sse_event');
|
|
stream.onmessage = function(e){
|
|
document.getElementById('price').innerHTML=e.data;
|
|
};
|
|
|
|
stream.onerror = function(e){
|
|
console.log(e);
|
|
};
|
|
}
|
|
|
|
read_data();
|
|
</script>
|
|
<p>Price: <span id="price"></span></p>
|
|
</body>
|