-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.bkp
40 lines (32 loc) · 1.14 KB
/
server.bkp
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const { names, ultimate } = require("./module1");
const animes = require("./module2");
const os = require("os");
const fs = require("fs");
const http = require("http");
/*
console.log(names);
console.log(animes);
console.log(os.cpus());
fs.readFile("./assets/text.txt", (error, data) => {
if (error) console.log(error);
else console.log(data.toString());
})
fs.writeFile("./assets/text.txt", "im so fast master", () => {
console.log("done sir")
})
Aynschornous
console.log(fs.readFileSync("./assets/text.txt").toString());
fs.writeFileSync("./assets/text.txt", "I'm actually faster");
*/
const HOSTNAME = "localhost";
const PORT = 4000;
const server = http.createServer((req, res) => {
console.log(req);
console.log(res);
res.writeHead(200, { "Content-Type": "text/html" });
res.write("<h5>Hello from the Server! 123</h5>");
res.end();
});
server.listen(PORT, HOSTNAME, () => {
console.log(`SERVER STATER ON http://${HOSTNAME}:${PORT}`);
})