Commit 8b68ba49 authored by nagayama15's avatar nagayama15

Add a simple wasm driver

parent 025d42c5
......@@ -12,7 +12,7 @@ const server = app.listen(port, () => {
app.get("/wasm/add.wasm", (req: express.Request, res: express.Response) => {
const binary = fs.readFileSync(`${__dirname}/../wasm/add.wasm`);
res.writeHead(200, { contentType: "application/wasm" });
res.writeHead(200, { "Content-Type": "application/wasm" });
res.end(binary);
});
......
......@@ -8,7 +8,16 @@
<body>
<h1>Watermark Server</h1>
<script>
console.log("Hello, world!");
(async () => {
const wasm = await WebAssembly.instantiateStreaming(
fetch("wasm/add.wasm")
);
const { add2, add3 } = wasm.instance.exports;
console.log(add2(42, 88));
console.log(add3(42, 88, 64));
})();
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment