JavaScript at Backend
Agenda
Agenda 1. What?
Agenda 1. What? 2. Installing
Agenda 1. What? 2. Installing 3. Hello World.
Agenda 1. What? 2. Installing 3. Hello World. 4. How to run NodeJS Application.
Agenda 1. What? 2. Installing 3. Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules
Agenda 1. What? 2. Installing 3. Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules ○ fs(file-system) (sync vs async)
Agenda 1. What? 2. Installing 3. Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules ○ fs(file-system) (sync vs async) ○ http/https (HTTP Server with NodeJS)
Agenda 1. What? 2. Installing 3. Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules ○ fs(file-system) (sync vs async) ○ http/https (HTTP Server with NodeJS) 6. Handling HTTP Request
About Me Amit Thakkar Tech Blogger @ CodeChutney.in JavaScript Lover Working on MEAN Stack Twitter: @amit_thakkar01 LinkedIn: linkedin.com/in/amitthakkar01 Facebook: facebook.com/amit.thakkar01
What?
Installing https://nodejs.org/download/
Hello World
You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at-Backend-NodeJS
How to run NodeJS App?
You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlink('test', function (err) { if (err) throw err; console.log('successfully deleted test'); }); })(require);
Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlink('test', function (err) { if (err) throw err; console.log('successfully deleted test'); }); })(require);
Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlink('test', function (err) { if (err) throw err; console.log('successfully deleted test'); }); })(require);
You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
Node Internal Modules: http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
Node Internal Modules: http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
Node Internal Modules: http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
Node Internal Modules: http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
Node Internal Modules: http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
Handling HTTP Request var requestHandler = function (request, response) { var data = ""; switch (request.url) { case "/" : data = "HelloWorld"; break; case "/me" : data = "This is Me!"; break; default : data = "You lose in space"; } response.writeHead(200, {"Content-Type": "text/plain"}); response.write(data); response.end(); };
Handling HTTP Request var requestHandler = function (request, response) { var data = ""; switch (request.url) { case "/" : data = "HelloWorld"; break; case "/me" : data = "This is Me!"; break; default : data = "You lose in space"; } response.writeHead(200, {"Content-Type": "text/plain"}); response.write(data); response.end(); };
Questions??
References: Create Basic HTTP Server with Node.js

Java script at backend nodejs

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
    Agenda 1. What? 2. Installing 3.Hello World. 4. How to run NodeJS Application.
  • 7.
    Agenda 1. What? 2. Installing 3.Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules
  • 8.
    Agenda 1. What? 2. Installing 3.Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules ○ fs(file-system) (sync vs async)
  • 9.
    Agenda 1. What? 2. Installing 3.Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules ○ fs(file-system) (sync vs async) ○ http/https (HTTP Server with NodeJS)
  • 10.
    Agenda 1. What? 2. Installing 3.Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules ○ fs(file-system) (sync vs async) ○ http/https (HTTP Server with NodeJS) 6. Handling HTTP Request
  • 11.
    About Me Amit Thakkar TechBlogger @ CodeChutney.in JavaScript Lover Working on MEAN Stack Twitter: @amit_thakkar01 LinkedIn: linkedin.com/in/amitthakkar01 Facebook: facebook.com/amit.thakkar01
  • 12.
  • 13.
  • 14.
  • 15.
    You can checkoutDemo form: https://github.com/AmitThakkar/JavaScript-at-Backend-NodeJS
  • 16.
    How to runNodeJS App?
  • 17.
    You can checkoutDemo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
  • 18.
    Node Internal Modules:fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
  • 19.
    Node Internal Modules:fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
  • 20.
    Node Internal Modules:fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
  • 21.
    Node Internal Modules:fs (function (require) { var fs = require('fs'); fs.unlink('test', function (err) { if (err) throw err; console.log('successfully deleted test'); }); })(require);
  • 22.
    Node Internal Modules:fs (function (require) { var fs = require('fs'); fs.unlink('test', function (err) { if (err) throw err; console.log('successfully deleted test'); }); })(require);
  • 23.
    Node Internal Modules:fs (function (require) { var fs = require('fs'); fs.unlink('test', function (err) { if (err) throw err; console.log('successfully deleted test'); }); })(require);
  • 24.
    You can checkoutDemo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
  • 25.
    Node Internal Modules:http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
  • 26.
    Node Internal Modules:http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
  • 27.
    Node Internal Modules:http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
  • 28.
    Node Internal Modules:http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
  • 29.
    Node Internal Modules:http var http = require("http"); var server = http.createServer(requestHandler); server.listen(9999, function() { console.log('Server running at http://localhost:9999/'); }); function requestHandler(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }
  • 30.
    You can checkoutDemo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
  • 31.
    Handling HTTP Request varrequestHandler = function (request, response) { var data = ""; switch (request.url) { case "/" : data = "HelloWorld"; break; case "/me" : data = "This is Me!"; break; default : data = "You lose in space"; } response.writeHead(200, {"Content-Type": "text/plain"}); response.write(data); response.end(); };
  • 32.
    Handling HTTP Request varrequestHandler = function (request, response) { var data = ""; switch (request.url) { case "/" : data = "HelloWorld"; break; case "/me" : data = "This is Me!"; break; default : data = "You lose in space"; } response.writeHead(200, {"Content-Type": "text/plain"}); response.write(data); response.end(); };
  • 33.
  • 34.
    References: Create Basic HTTPServer with Node.js