wasm-http-server/docs/index.html

32 lines
787 B
HTML
Raw Normal View History

2019-11-27 11:20:52 +01:00
<!DOCTYPE html>
<html>
2019-11-27 11:44:54 +01:00
<head>
<title>go-wasm-http-server demo</title>
<script>
2019-11-27 11:47:20 +01:00
async function hello() {
2019-11-27 11:44:54 +01:00
res=await fetch('api/hello', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: document.querySelector("#name").value })
})
2019-11-27 11:47:20 +01:00
const { message } = await res.json()
alert(message)
2019-11-27 11:44:54 +01:00
}
</script>
</head>
2019-11-27 11:20:52 +01:00
<body>
2019-11-27 11:44:54 +01:00
<label for="name">Name : </label><input id="name" value="World">
2019-11-27 11:50:23 +01:00
<button onclick="hello()">Hello</button>
2019-11-27 11:20:52 +01:00
<script>
2019-11-27 11:54:51 +01:00
(async () => {
try {
await navigator.serviceWorker.register('sw.js')
} catch (e) {
console.error(e)
}
})()
2019-11-27 11:20:52 +01:00
</script>
</body>
</html>