-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (44 loc) · 1.12 KB
/
index.html
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<title>SSE Example</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 50px;
}
button {
padding: 10px 20px;
font-size: 16px;
background-color: #007BFF;
color: #FFF;
border: none;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
#output {
margin-top: 20px;
font-size: 18px;
}
</style>
<script>
const eventSource = new EventSource('/events');
eventSource.onmessage = (event) => {
const output = document.getElementById('output');
const eventData = event.data;
output.innerHTML = 'Received: ' + eventData;
};
function sendEvent() {
fetch('/send-event', { method: 'POST' });
}
</script>
</head>
<body>
<button onclick="sendEvent()">Send Event</button>
<div id="output"></div>
</body>
</html>