-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_internalModules.js
64 lines (54 loc) · 1.43 KB
/
03_internalModules.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// INTERNAL MODULES / INBUILT MODULES
// 1. PATH
const path = require("path");
const extensionName = path.extname("index.js");
console.log(extensionName)
console.log(path.join(__dirname, "index.js"));
// 2. OS
const os = require("os");
// console.log(os.arch());
// console.log(os.platform());
// console.log(os.cpus().length);
// console.log(os.userInfo());
console.log(os.version())
// 3. FS
const fs = require("fs");
const { log } = require("console");
// fs.mkdir("test", (err) => {
// if (err) {
// console.log(err);
// }
// else {
// console.log("Folder created successfully");
// }
// });
// fs.readFile("Data.txt", (err, data) => {
// if (err) {
// console.log(err);
// }
// else {
// console.log(data.toString());
// }
// });
// fs.writeFile("Data.txt", "Hey I'm Akkya and I'm a Web Developer", (err) => {
// if (err) {
// console.log(err);
// }
// else {
// console.log("File written successfully")
// }
// })
// fs.appendFile("Data.txt", "\nThank you", (err) => {
// if (err) {
// console.log(err);
// }
// else {
// console.log("Data added successfully");
// }
// })
// 4. HTTP
const http = require("http")
const server = http.createServer((req, res) => {
res.end("<h1><center>Hello World</center></h1>")
})
server.listen(5000, () => console.log("Server is running"));