├── .gitignore ├── JsonData.js ├── index.js ├── package-lock.json └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directories\ 2 | /node_modules -------------------------------------------------------------------------------- /JsonData.js: -------------------------------------------------------------------------------- 1 | const data = [ 2 | { 3 | "What is NodeJS" : "Node.js is an open-source, server-side JavaScript runtime environment that allows developers to run JavaScript code outside of a web browser. It is built on the V8 JavaScript engine developed by Google, which is also used in the Chrome web browser. Node.js enables developers to write server-side applications using JavaScript, a language traditionally associated with client-side scripting in web browsers." 4 | } 5 | ]; 6 | 7 | module.exports = data; 8 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const http = require("http"); 2 | const port = 3000; 3 | 4 | const jsonData = require("./JsonData") 5 | 6 | 7 | const app = http.createServer((req, res)=>{ 8 | if(req.url === '/'){ 9 | res.write(""); 10 | res.write(""); 11 | res.write("

What is Node JS

"); 12 | res.write(""); 19 | res.write(""); 20 | res.write(""); 21 | res.end() 22 | } 23 | else if(req.url === "/JsonData"){ 24 | const data = JSON.stringify(jsonData) 25 | res.write(data); 26 | res.end(); 27 | } 28 | else{ 29 | res.write("This is Error Page"); 30 | res.end(); 31 | } 32 | }) 33 | 34 | app.listen(port, ()=>{ 35 | console.log(`Server is Runing on Port http://localhost:${port}`) 36 | }); 37 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "handson-1", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "handson-1", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "nodemon": "^3.0.1" 13 | } 14 | }, 15 | "node_modules/abbrev": { 16 | "version": "1.1.1", 17 | "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", 18 | "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" 19 | }, 20 | "node_modules/anymatch": { 21 | "version": "3.1.3", 22 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", 23 | "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", 24 | "dependencies": { 25 | "normalize-path": "^3.0.0", 26 | "picomatch": "^2.0.4" 27 | }, 28 | "engines": { 29 | "node": ">= 8" 30 | } 31 | }, 32 | "node_modules/balanced-match": { 33 | "version": "1.0.2", 34 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 35 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" 36 | }, 37 | "node_modules/binary-extensions": { 38 | "version": "2.2.0", 39 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", 40 | "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", 41 | "engines": { 42 | "node": ">=8" 43 | } 44 | }, 45 | "node_modules/brace-expansion": { 46 | "version": "1.1.11", 47 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 48 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 49 | "dependencies": { 50 | "balanced-match": "^1.0.0", 51 | "concat-map": "0.0.1" 52 | } 53 | }, 54 | "node_modules/braces": { 55 | "version": "3.0.2", 56 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 57 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 58 | "dependencies": { 59 | "fill-range": "^7.0.1" 60 | }, 61 | "engines": { 62 | "node": ">=8" 63 | } 64 | }, 65 | "node_modules/chokidar": { 66 | "version": "3.5.3", 67 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", 68 | "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", 69 | "funding": [ 70 | { 71 | "type": "individual", 72 | "url": "https://paulmillr.com/funding/" 73 | } 74 | ], 75 | "dependencies": { 76 | "anymatch": "~3.1.2", 77 | "braces": "~3.0.2", 78 | "glob-parent": "~5.1.2", 79 | "is-binary-path": "~2.1.0", 80 | "is-glob": "~4.0.1", 81 | "normalize-path": "~3.0.0", 82 | "readdirp": "~3.6.0" 83 | }, 84 | "engines": { 85 | "node": ">= 8.10.0" 86 | }, 87 | "optionalDependencies": { 88 | "fsevents": "~2.3.2" 89 | } 90 | }, 91 | "node_modules/concat-map": { 92 | "version": "0.0.1", 93 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 94 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" 95 | }, 96 | "node_modules/debug": { 97 | "version": "3.2.7", 98 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", 99 | "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", 100 | "dependencies": { 101 | "ms": "^2.1.1" 102 | } 103 | }, 104 | "node_modules/fill-range": { 105 | "version": "7.0.1", 106 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 107 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 108 | "dependencies": { 109 | "to-regex-range": "^5.0.1" 110 | }, 111 | "engines": { 112 | "node": ">=8" 113 | } 114 | }, 115 | "node_modules/fsevents": { 116 | "version": "2.3.3", 117 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", 118 | "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", 119 | "hasInstallScript": true, 120 | "optional": true, 121 | "os": [ 122 | "darwin" 123 | ], 124 | "engines": { 125 | "node": "^8.16.0 || ^10.6.0 || >=11.0.0" 126 | } 127 | }, 128 | "node_modules/glob-parent": { 129 | "version": "5.1.2", 130 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 131 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 132 | "dependencies": { 133 | "is-glob": "^4.0.1" 134 | }, 135 | "engines": { 136 | "node": ">= 6" 137 | } 138 | }, 139 | "node_modules/has-flag": { 140 | "version": "3.0.0", 141 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 142 | "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", 143 | "engines": { 144 | "node": ">=4" 145 | } 146 | }, 147 | "node_modules/ignore-by-default": { 148 | "version": "1.0.1", 149 | "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", 150 | "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" 151 | }, 152 | "node_modules/is-binary-path": { 153 | "version": "2.1.0", 154 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 155 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 156 | "dependencies": { 157 | "binary-extensions": "^2.0.0" 158 | }, 159 | "engines": { 160 | "node": ">=8" 161 | } 162 | }, 163 | "node_modules/is-extglob": { 164 | "version": "2.1.1", 165 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 166 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 167 | "engines": { 168 | "node": ">=0.10.0" 169 | } 170 | }, 171 | "node_modules/is-glob": { 172 | "version": "4.0.3", 173 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 174 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 175 | "dependencies": { 176 | "is-extglob": "^2.1.1" 177 | }, 178 | "engines": { 179 | "node": ">=0.10.0" 180 | } 181 | }, 182 | "node_modules/is-number": { 183 | "version": "7.0.0", 184 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 185 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 186 | "engines": { 187 | "node": ">=0.12.0" 188 | } 189 | }, 190 | "node_modules/lru-cache": { 191 | "version": "6.0.0", 192 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", 193 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", 194 | "dependencies": { 195 | "yallist": "^4.0.0" 196 | }, 197 | "engines": { 198 | "node": ">=10" 199 | } 200 | }, 201 | "node_modules/minimatch": { 202 | "version": "3.1.2", 203 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 204 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 205 | "dependencies": { 206 | "brace-expansion": "^1.1.7" 207 | }, 208 | "engines": { 209 | "node": "*" 210 | } 211 | }, 212 | "node_modules/ms": { 213 | "version": "2.1.3", 214 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 215 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 216 | }, 217 | "node_modules/nodemon": { 218 | "version": "3.0.1", 219 | "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", 220 | "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", 221 | "dependencies": { 222 | "chokidar": "^3.5.2", 223 | "debug": "^3.2.7", 224 | "ignore-by-default": "^1.0.1", 225 | "minimatch": "^3.1.2", 226 | "pstree.remy": "^1.1.8", 227 | "semver": "^7.5.3", 228 | "simple-update-notifier": "^2.0.0", 229 | "supports-color": "^5.5.0", 230 | "touch": "^3.1.0", 231 | "undefsafe": "^2.0.5" 232 | }, 233 | "bin": { 234 | "nodemon": "bin/nodemon.js" 235 | }, 236 | "engines": { 237 | "node": ">=10" 238 | }, 239 | "funding": { 240 | "type": "opencollective", 241 | "url": "https://opencollective.com/nodemon" 242 | } 243 | }, 244 | "node_modules/nopt": { 245 | "version": "1.0.10", 246 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", 247 | "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", 248 | "dependencies": { 249 | "abbrev": "1" 250 | }, 251 | "bin": { 252 | "nopt": "bin/nopt.js" 253 | }, 254 | "engines": { 255 | "node": "*" 256 | } 257 | }, 258 | "node_modules/normalize-path": { 259 | "version": "3.0.0", 260 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 261 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 262 | "engines": { 263 | "node": ">=0.10.0" 264 | } 265 | }, 266 | "node_modules/picomatch": { 267 | "version": "2.3.1", 268 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 269 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 270 | "engines": { 271 | "node": ">=8.6" 272 | }, 273 | "funding": { 274 | "url": "https://github.com/sponsors/jonschlinkert" 275 | } 276 | }, 277 | "node_modules/pstree.remy": { 278 | "version": "1.1.8", 279 | "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", 280 | "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==" 281 | }, 282 | "node_modules/readdirp": { 283 | "version": "3.6.0", 284 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", 285 | "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", 286 | "dependencies": { 287 | "picomatch": "^2.2.1" 288 | }, 289 | "engines": { 290 | "node": ">=8.10.0" 291 | } 292 | }, 293 | "node_modules/semver": { 294 | "version": "7.5.4", 295 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", 296 | "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", 297 | "dependencies": { 298 | "lru-cache": "^6.0.0" 299 | }, 300 | "bin": { 301 | "semver": "bin/semver.js" 302 | }, 303 | "engines": { 304 | "node": ">=10" 305 | } 306 | }, 307 | "node_modules/simple-update-notifier": { 308 | "version": "2.0.0", 309 | "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", 310 | "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", 311 | "dependencies": { 312 | "semver": "^7.5.3" 313 | }, 314 | "engines": { 315 | "node": ">=10" 316 | } 317 | }, 318 | "node_modules/supports-color": { 319 | "version": "5.5.0", 320 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 321 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 322 | "dependencies": { 323 | "has-flag": "^3.0.0" 324 | }, 325 | "engines": { 326 | "node": ">=4" 327 | } 328 | }, 329 | "node_modules/to-regex-range": { 330 | "version": "5.0.1", 331 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 332 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 333 | "dependencies": { 334 | "is-number": "^7.0.0" 335 | }, 336 | "engines": { 337 | "node": ">=8.0" 338 | } 339 | }, 340 | "node_modules/touch": { 341 | "version": "3.1.0", 342 | "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", 343 | "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", 344 | "dependencies": { 345 | "nopt": "~1.0.10" 346 | }, 347 | "bin": { 348 | "nodetouch": "bin/nodetouch.js" 349 | } 350 | }, 351 | "node_modules/undefsafe": { 352 | "version": "2.0.5", 353 | "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", 354 | "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==" 355 | }, 356 | "node_modules/yallist": { 357 | "version": "4.0.0", 358 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", 359 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" 360 | } 361 | } 362 | } 363 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "handson-1", 3 | "version": "1.0.0", 4 | "description": "\"This is Node handson 1\"", 5 | "main": "index.js", 6 | "scripts": { 7 | "start" : "nodemon index.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "\"Nitin Rajput", 11 | "license": "ISC", 12 | "dependencies": { 13 | "nodemon": "^3.0.1" 14 | } 15 | } 16 | --------------------------------------------------------------------------------