-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.ts
More file actions
25 lines (22 loc) · 751 Bytes
/
node.ts
File metadata and controls
25 lines (22 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// import fs = require("fs");
// import http = require("http");
// import path = require("path");
import fs = require("node:fs");
import http = require("node:http");
import path from "node:path";
const server = http
.createServer((req, res) => {
setTimeout(() => {
console.log("hello");
}, 1000); // Node에서는 setTimeout의 return값이 NodeJS.Timeout으로 되어있음
window.setTimeout(() => {}, 1000); // 브라우저에서는 setTimeout의 return값이 number로 되어있는데
fs.readFile(path.join(__dirname, "index.html"), (err, data) => {
res.writeHead(200);
res.end(data);
});
})
.listen(8080, () => {
console.log("서버 시작됨");
});
exports = server;
module.exports = server;