Skip to content

Commit 5aeff7f

Browse files
committed
Fix answer of forum
1 parent 4caac13 commit 5aeff7f

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

docs/3-web-servers/06-get-post/_samples/forum/main.mjs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import fs from "fs";
21
import express from "express";
3-
import ejs from "ejs";
42

53
const app = express();
64

@@ -9,9 +7,24 @@ const messages = [];
97
app.use(express.urlencoded({ extended: true }));
108

119
app.get("/", (request, response) => {
12-
const template = fs.readFileSync("template.ejs", "utf-8");
13-
const html = ejs.render(template, { messages: messages });
14-
response.send(html);
10+
response.send(`
11+
<!doctype html>
12+
<html lang="ja">
13+
<head>
14+
<meta charset="UTF-8" />
15+
<title>Document</title>
16+
</head>
17+
<body>
18+
<ul>
19+
${messages.map((message) => `<li>${message}</li>`).join("")}
20+
</ul>
21+
<form action="/send" method="post">
22+
<input name="message" />
23+
<button>送信</button>
24+
</form>
25+
</body>
26+
</html>
27+
`);
1528
});
1629

1730
app.post("/send", (request, response) => {

docs/3-web-servers/06-get-post/_samples/forum/template.ejs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)