wasm-http-server/docs/index.html

27 lines
811 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>
2019-12-02 16:58:20 +01:00
<script src="https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@b4be701615d284296a4a1aaa852db02f139969ee/index.js"></script>
2019-11-27 11:44:54 +01:00
<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-12-02 16:52:40 +01:00
wasmhttp.register('api.wasm', { base: 'api' })
2019-11-27 11:20:52 +01:00
</script>
</body>
</html>