Commit 025d42c5 authored by nagayama15's avatar nagayama15

Serve static files

parent 67780e69
import * as fs from "fs";
import * as express from "express";
const port = 3000;
......@@ -8,6 +9,11 @@ const server = app.listen(port, () => {
console.log(`server listening at port ${port}`);
});
app.get("/", (req: express.Request, res: express.Response) => {
res.send("Hello, world!");
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.end(binary);
});
app.use(express.static(`${__dirname}/../static`));
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Watermark Server</title>
</head>
<body>
<h1>Watermark Server</h1>
<script>
console.log("Hello, world!");
</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