File size: 625 Bytes
319ab81
 
 
 
 
 
 
08d085a
 
319ab81
 
 
 
f0af7d8
08d085a
 
17cb065
ce61050
92b58b6
17cb065
08d085a
3a9492e
5008097
319ab81
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html>
  <head>
    <title>Display</title>
  </head>
  <body>
    <h1>
      <div class="text"></div>
      <div class="next-text"></div>
    </h1>

    <script>
      window.onload = () => {
        const eventSource = new EventSource('http://localhost:8343/test');
        const allText = document.querySelector('.text');
        const nextText = document.querySelector('.next-text');
        let prevText = ""
        eventSource.onmessage = (e) => {
          let message = e.data;
          allText.innerHTML += message;

          console.log(e.data);
        };
      }
    </script>
  </body>
</html>