Skip to content

Commit 31f0493

Browse files
committed
Merge branch 'master' into fix-db-answer
2 parents 2df9649 + 46822a0 commit 31f0493

File tree

28 files changed

+3272
-13035
lines changed

28 files changed

+3272
-13035
lines changed

docs/3-web-servers/04-server/_samples/complex-html/main.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const app = express();
44
const names = ["田中", "鈴木", "佐藤"];
55
app.get("/", (request, response) => {
66
response.send(`
7-
<!DOCTYPE html>
7+
<!doctype html>
88
<html lang="ja">
99
<head>
1010
<meta charset="utf-8" />

docs/3-web-servers/04-server/_samples/server-or-client/main.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const app = express();
33

44
app.get("/", (request, response) => {
55
response.send(`
6-
<!DOCTYPE html>
6+
<!doctype html>
77
<html lang="ja">
88
<head>
99
<meta charset="utf-8" />

docs/3-web-servers/04-server/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Web の世界で用いられるプロトコルは、通常 **HTTP** と呼ばれ
101101

102102
![HTTP](./basic-http.png)
103103

104-
Web サーバーにアクセスするために用いた `http://localhost:3000/` のうち、http はプロトコルを、localhost:3000 はサーバーの所在地を表しています (localhost は自分のコンピューターを指します)。
104+
Web サーバーにアクセスするために用いた `http://localhost:3000/` のうち、`http` はプロトコルを、`localhost:3000` はサーバーの所在地を表しています (`localhost` は自分のコンピューターを指します)。
105105

106106
## 静的ホスティング
107107

@@ -161,7 +161,7 @@ const app = express();
161161
const names = ["田中", "鈴木", "佐藤"];
162162
app.get("/", (request, response) => {
163163
response.send(`
164-
<!DOCTYPE html>
164+
<!doctype html>
165165
<html lang="ja">
166166
<head>
167167
<meta charset="utf-8" />

docs/3-web-servers/05-form/_samples/book-search-system/main.mjs

Lines changed: 16 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

@@ -18,9 +16,22 @@ app.get("/send", (request, response) => {
1816
const selectedBooks = books.filter(
1917
(book) => book.author === request.query.author,
2018
);
21-
const template = fs.readFileSync("template.ejs", "utf-8");
22-
const html = ejs.render(template, { selectedBooks: selectedBooks });
23-
response.send(html);
19+
response.send(`
20+
<!doctype html>
21+
<html lang="ja">
22+
<head>
23+
<meta charset="UTF-8" />
24+
<title>Document</title>
25+
</head>
26+
<body>
27+
<ul>
28+
${selectedBooks
29+
.map((selectedBook) => `<li>${selectedBook.title}</li>`)
30+
.join("")}
31+
</ul>
32+
</body>
33+
</html>
34+
`);
2435
});
2536

2637
app.listen(3000);

docs/3-web-servers/05-form/_samples/book-search-system/template.ejs

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

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

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

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

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

docs/3-web-servers/06-get-post/_samples/bulletin-board/.gitignore renamed to docs/3-web-servers/06-get-post/_samples/forum/.gitignore

File renamed without changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import express from "express";
2+
3+
const app = express();
4+
5+
const messages = [];
6+
7+
app.use(express.urlencoded({ extended: true }));
8+
9+
app.get("/", (request, response) => {
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+
`);
28+
});
29+
30+
app.post("/send", (request, response) => {
31+
messages.push(request.body.message);
32+
response.send("送信しました");
33+
});
34+
35+
app.listen(3000);

docs/3-web-servers/06-get-post/_samples/bulletin-board/package-lock.json renamed to docs/3-web-servers/06-get-post/_samples/forum/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)