O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Java script at backend nodejs

1.370 visualizações

Publicada em

N

Publicada em: Tecnologia
  • Seja o primeiro a comentar

Java script at backend nodejs

  1. 1. JavaScript at Backend
  2. 2. Agenda
  3. 3. Agenda 1. What?
  4. 4. Agenda 1. What? 2. Installing
  5. 5. Agenda 1. What? 2. Installing 3. Hello World.
  6. 6. Agenda 1. What? 2. Installing 3. Hello World. 4. How to run NodeJS Application.
  7. 7. Agenda 1. What? 2. Installing 3. Hello World. 4. How to run NodeJS Application. 5. NodeJS Internal Modules
  8. 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. 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. 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. 11. 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
  12. 12. What?
  13. 13. Installing https://nodejs.org/download/
  14. 14. Hello World
  15. 15. You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at-Backend-NodeJS
  16. 16. How to run NodeJS App?
  17. 17. You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
  18. 18. Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
  19. 19. Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
  20. 20. Node Internal Modules: fs (function (require) { var fs = require('fs'); fs.unlinkSync('test2'); console.log('successfully deleted test2'); })(require);
  21. 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. 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. 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. 24. You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
  25. 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. 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. 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. 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. 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. 30. You can checkout Demo form: https://github.com/AmitThakkar/JavaScript-at- Backend-NodeJS
  31. 31. 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(); };
  32. 32. 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(); };
  33. 33. Questions??
  34. 34. References: Create Basic HTTP Server with Node.js

×