/
index.html
34 lines (33 loc) · 978 Bytes
/
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
<html lang="utf-8">
<head>
<title>Webpush Server</title>
<script>
const sendEndpoint = "http://localhost:8000/send";
const sendNotification = async () => {
const data = document.getElementById("notification").value;
const res = await fetch(sendEndpoint, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(JSON.parse(data))
});
return res.status === 200 ? res.json() : false;
};
</script>
</head>
<body>
<div id="root">
<textarea rows="3" cols="70" id="notification">
{"title": "Notification title", "body": "View in my site.", "url":"https://mysite.com"}</textarea
>
<input
type="button"
onClick="javascript:sendNotification();"
value="Send notification"
/>
</div>
<script src="/register.js"></script>
</body>
</html>