Skip to content

Commit

Permalink
added SSE
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminbck committed Jun 22, 2024
1 parent 5035798 commit ec6043f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ <h1>Modals</h1>
<h1>Logs</h1>
<div id="User">User</div>
<div id="Chat">Chat</div>

<h1>Server-Sent Events</h1>
<div id="sse-data"></div>

</main>

<script src="https://telegram.org/js/telegram-web-app.js"></script>
Expand Down Expand Up @@ -94,5 +98,13 @@ <h1>Logs</h1>

</script>

<script>
const eventSource = new EventSource('http://melendriu.homepc.it:8888/events');
eventSource.onmessage = function(event) {
const dataElement = document.getElementById('sse-data');
dataElement.innerHTML += event.data + '<br>';
};
</script>

</body>
</html>

0 comments on commit ec6043f

Please sign in to comment.