Node.js Lab

1,246 views

Published on

Node.js Lab
http://leonguyen.com

Node.js Lab

  1. 1. LeoNguyen.com
  2. 2. Outline - Node.js References (leonguyen.com/nodejs/references.html) - Express.js References (leonguyen.com/nodejs/expressjs/references/) - Node.js Sites (leonguyen.com/nodejs/Sites.html) - Lab 01: Node.js - Lab 02: Express.js
  3. 3. Lab 01 Node.js
  4. 4. Outline - Lab 01: Introduction to Node.js
  5. 5. Outline - Install Node.js on Windows - Install Node.js on Linux - Write a Hello Console - Write a Hello HTTP - Write a Hello TCP - Write a Hello UDP
  6. 6. Overview
  7. 7. Overview (cont)
  8. 8. Overview (cont)
  9. 9. Overview (cont)
  10. 10. Exercise 1 Install Node.js
  11. 11. Task 1 - On Windows - Goto Node.js download site nodejs.org/download (See: youtu. be/n9cs8Bmb6KU) - Check version: using command node -v (See: youtu.be/-hZ9-qkxxOc)
  12. 12. Task 1 - On Linux - Install on Ubuntu (See: youtu.be/8widdkdSo58) - Install on CentOS (See: youtu.be/bPObquO4FCM) - Check version: using command node -v (See: youtu.be/-hZ9-qkxxOc)
  13. 13. Exercise 2 Write a Hello Console
  14. 14. Task 1 - Write a hello-console.js - Enter code: https://gist.github.com/leonguyen/6472852
  15. 15. Task 2 - Run - Using command: node hello-console.js (See: youtu.be/LxGlcdR53To)
  16. 16. Exercise 3 Write a Hello HTTP
  17. 17. Task 1 - Write a hello-http.js - Enter code: https://gist.github.com/leonguyen/6492146
  18. 18. Task 2 - Run - Using command: node hello-http.js (See: youtu.be/IpafeSP6_dg)
  19. 19. Task 3 - Run - Go to: http://localhost:8000/
  20. 20. Exercise 4 Write a Hello TCP
  21. 21. Task 1 - Write a hello-tcp.js - Enter code: https://gist.github.com/leonguyen/6492200
  22. 22. Task 2 - Run - Using command: node hello-tcp.js (See: youtu.be/5_dVVRmcjWg)
  23. 23. Exercise 5 Write a Hello UDP
  24. 24. Task 1 - Write a hello-udp.js - Enter code: https://gist.github.com/leonguyen/6492554
  25. 25. Task 2 - Write a client-hello-udp.js - Enter code: https://gist.github.com/leonguyen/6492588
  26. 26. Task 3 - Run UDP - Using command: node hello-udp.js (See: youtu.be/3SzAxXu2zDI)
  27. 27. Task 4 - Run UDP Client - Using command: node client-hello-udp.js (See: youtu. be/syyp0TWQd4U)
  28. 28. Lab 02 Express.js
  29. 29. Outline - Install and config Express.js - Generate an application - MySQL
  30. 30. Exercise 1 Install and config Express.js
  31. 31. Task 1 - Create package.json - Check NPM: using command npm -v (See: youtu.be/_x3EzBCBd_o) - Enter code: https://gist.github.com/leonguyen/6504935
  32. 32. Task 2 - Install Express.js - Install Express: using command npm install (See: youtu. be/umjcT1sH22Q) or npm install -g express (for available from anywhere) - Check Express: using command express --version (See: youtu. be/a8H41rePUJM)
  33. 33. Exercise 2 Generate an application
  34. 34. Task 1 - Generate an application - Using command express --sessions --css stylus --ejs [nodeapp] (See: youtu.be/7QMhdISI-7s)
  35. 35. Task 2 - Install dependencies - Using command npm install (See: youtu.be/qgi16SrXcTI)
  36. 36. Task 3 - Run - Using command node app (See: youtu.be/xFBKkD4xC5w)
  37. 37. Task 4 - Run - Go to: http://localhost:3000 and http://localhost:3000/users
  38. 38. Exercise 3 MySQL
  39. 39. Task 1 - Install MySQL - Using command npm install mysql See: youtu.be/uEWKuQQiPVs, youtu.be/CB80P8_i7gg (CentOS)

×