annotate website/src/examples/sse_pull.html @ 1812:f44dcb3fedf7

docs - add code block
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Jun 2024 14:41:48 -0600
parents 9713f7fd50b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1738
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 <!doctype html>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 <html>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 <head>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 <style>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 body {
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 white-space: pre;
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 }
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 </style>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 <script>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 let eventSource = new EventSource(location.origin+'/examples/sse_push.html');
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 eventSource.onmessage = function(event) {
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 document.body.textContent = event.data;
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 };
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 </script>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 </head>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 <body>pull server-sent events</body>
9713f7fd50b3 server-sent events
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 </html>