2019-11-27 11:20:52 +01:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
2019-11-27 11:44:54 +01:00
|
|
|
<head>
|
2021-01-22 15:39:26 +01:00
|
|
|
<title>go-wasm-http-server hello demo</title>
|
2019-11-27 11:44:54 +01:00
|
|
|
<script>
|
2021-01-22 15:28:37 +01:00
|
|
|
navigator.serviceWorker.register('sw.js')
|
2021-01-21 23:07:42 +01:00
|
|
|
|
2019-11-27 11:47:20 +01:00
|
|
|
async function hello() {
|
2021-01-21 22:00:21 +01:00
|
|
|
res = await fetch('api/hello', {
|
2019-11-27 11:44:54 +01:00
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
2021-01-21 22:00:21 +01:00
|
|
|
body: JSON.stringify({ name: document.querySelector("#name").value })
|
2019-11-27 11:44:54 +01:00
|
|
|
})
|
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>
|
2021-01-22 00:42:01 +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
|
|
|
</body>
|
2021-01-22 15:39:26 +01:00
|
|
|
</html>
|