Skip to content

Commit 88c8a5f

Browse files
committed
draft
1 parent d42c71c commit 88c8a5f

18 files changed

Lines changed: 403 additions & 22 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import express from "express";
2+
const app = express();
3+
4+
app.use(express.static("./public"));
5+
6+
app.listen(3000);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "browser-module",
3+
"dependencies": {
4+
"express": "^5.1.0"
5+
}
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="ja">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>モジュールの例</title>
6+
</head>
7+
<body>
8+
<h1>計算結果</h1>
9+
<p id="result"></p>
10+
<script type="module" src="./main.js"></script>
11+
</body>
12+
</html>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { add, multiply } from "./math.js";
2+
3+
const sum = add(3, 4);
4+
const product = multiply(3, 4);
5+
6+
document.getElementById("result").textContent = `3 + 4 = ${sum}, 3 × 4 = ${product}`;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function add(a, b) {
2+
return a + b;
3+
}
4+
5+
export function multiply(a, b) {
6+
return a * b;
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import express from "express";
2+
const app = express();
3+
4+
app.use(express.static("./public"));
5+
6+
app.get("/weather", (request, response) => {
7+
response.send("晴れ");
8+
});
9+
10+
app.listen(3000);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "fetch-weather",
3+
"dependencies": {
4+
"express": "^5.1.0"
5+
}
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="ja">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>天気予報</title>
6+
</head>
7+
<body>
8+
<button id="fetch-button">天気予報を見る</button>
9+
<script src="./script.js"></script>
10+
</body>
11+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
document.getElementById("fetch-button").onclick = async () => {
2+
const response = await fetch("/weather");
3+
const weather = await response.text();
4+
alert(weather);
5+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import express from "express";
2+
const app = express();
3+
4+
app.use(express.static("./public"));
5+
6+
app.get("/nikkei", (request, response) => {
7+
const nikkei = Math.floor(Math.random() * 20000) + 20000;
8+
response.send(`${nikkei}`);
9+
});
10+
11+
app.listen(3000);

0 commit comments

Comments
 (0)