wasm-http-server/docs/index.html
2021-01-21 22:01:57 +01:00

27 lines
779 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>go-wasm-http-server demo</title>
<script src="https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@latest/index.js"></script>
<script>
async function hello() {
res = await fetch('api/hello', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ name: document.querySelector("#name").value })
})
const { message } = await res.json()
alert(message)
}
</script>
</head>
<body>
<label for="name">Name : </label><input id="name" value="World">
<button onclick="hello()">Hello</button>
<script>
wasmhttp.register('api.wasm', { base: 'api' })
</script>
</body>
</html>