├── first node.js ├── rohan.txt ├── osmodule.js ├── second.js ├── fs module.js ├── path module.js ├── package.json ├── blocking or non-blocking.js ├── serving html by backend.js ├── tut63.js └── tut61.html /first node.js: -------------------------------------------------------------------------------- 1 | const harry = require("./second"); 2 | 3 | console.log("hello world", harry) 4 | -------------------------------------------------------------------------------- /rohan.txt: -------------------------------------------------------------------------------- 1 | Hello I am Adam Warlock or Starlord or warlord 2 | and I am the student of Ra's Ghul -------------------------------------------------------------------------------- /osmodule.js: -------------------------------------------------------------------------------- 1 | const os = require('os'); 2 | 3 | console.log(os.freemem()) 4 | console.log(os.homedir()) 5 | console.log(os.hostname()) 6 | console.log(os.platform()) 7 | console.log(os.type()) -------------------------------------------------------------------------------- /second.js: -------------------------------------------------------------------------------- 1 | // (function(exports,require,nodule,_filename,_dirname){ 2 | 3 | harry = { 4 | name:"harry", 5 | favNum:3, 6 | developer: true 7 | } 8 | console.log(exports,require,nodule,_filename,_dirname) 9 | module.export = harry; 10 | // }) -------------------------------------------------------------------------------- /fs module.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | let text = fs.readFileSync("dele.txt", "utf-8"); 3 | text = text.replace("brower","program") 4 | 5 | console.log("The content is") 6 | console.log(text); 7 | 8 | console.log("creating a new file") 9 | fs.writeFileSync("rohan.txt", text) -------------------------------------------------------------------------------- /path module.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | 4 | const a = path.basename('C:\\temp\\myfile.html'); 5 | const a2 = path.dirname('C:\\temp\\myfile.html'); 6 | console.log(a) 7 | console.log(a2) 8 | 9 | const a3 = path.extname(__filename) 10 | console.log(__filename,a3) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fardin", 3 | "version": "1.0.0", 4 | "description": "its an amazing package", 5 | "main": "first node.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "fardin", 10 | "license": "ISC", 11 | "dependencies": {}, 12 | "devDependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /blocking or non-blocking.js: -------------------------------------------------------------------------------- 1 | // Synchronous or blocking 2 | //line by line execution 3 | 4 | /*Asymchronous or non-blocking 5 | line by line exexution not guaranteed 6 | callback will fire */ 7 | 8 | 9 | const fs = require("fs"); 10 | fs.readFile("dele.txt", "utf-8", (err,data)=>{ 11 | console.log(err,data) 12 | }); 13 | console.log("This is the message") -------------------------------------------------------------------------------- /serving html by backend.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | const fs = require('fs') 3 | const fileContent = fs.readFileSync('tut61.html') 4 | 5 | const server = http.createServer((req, res)=>{ 6 | 7 | res.writeHead(200, {'content-type':'text/html'}) 8 | res.end(fileContent) 9 | }) 10 | server.listen(80, '127.0.0.1', ()=>{ 11 | console.log("Listening on port 80") 12 | }) -------------------------------------------------------------------------------- /tut63.js: -------------------------------------------------------------------------------- 1 | console.log("Hello world"); 2 | 3 | const http = require('http'); 4 | 5 | const hostname = '127.0.0.1'; 6 | const port = 3000; 7 | 8 | const server = http.createServer((req, res) => { 9 | res.statusCode = 200; 10 | res.setHeader('Content-Type', 'text/html'); 11 | // res.end('Hello World This is Adam Warlock'); 12 | res.end(` 13 | 14 | 15 | 16 | 17 | 18 | Pseudo selectors & more designing 19 | 57 | 58 | 59 |
60 |

This is my heading

61 |

Lorem ipsum dolor sit amet consectetur adipisicing elit. Obcaecati, reprehenderit. Quam culpa eius aliquam id cumque saepe, provident odio sed eos quia nihil modi error voluptate vero autem quibusdam aperiam exercitationem! Quam, consequuntur velit.

62 | Read more 63 | 64 |
65 | 66 | `); 67 | }); 68 | 69 | server.listen(port, hostname, () => { 70 | console.log(`Server running at http://${hostname}:${port}/`); 71 | }); -------------------------------------------------------------------------------- /tut61.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Math Object 8 | 9 | 10 |
11 |

This is math object tutorial

12 |
13 | 75 | 76 | 77 | --------------------------------------------------------------------------------