Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap
Learn how to build a web server with Node JS. This Node.js tutorial for Beginners will walk you through building a web server with only Node JS - no framework required. This will help you build foundational knowledge of Node.js which will help when the Express JS framework is introduced later in this Node JS tutorial series.
🚩 Subscribe ➜ https://bit.ly/3nGHmNn
🚀 This lesson is part of a Node.js for Beginners tutorial series playlist:
https://www.youtube.com/playlist?list=PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw
🔗 Source Code: https://github.com/gitdagray/nodejs_web_server
How to Build a Web Server with Node JS | Node.js Tutorials for Beginners
(
00:00) Intro
(
00:05) Welcome
(
00:14) Overview
(
00:28) Project Setup
(
03:01) Import modules / dependencies
(
04:33) A minimal server
(
08:02) Two inefficient approaches
(
11:06) Setting the Content-Type
(
13:11) Setting the file path
(
15:59) Make the html extension optional
(
17:22) Does the requested file exist?
(
18:18) Routing redirects
(
22:48) Basic serveFile function
(
25:17) Calling the serveFile function
(
28:20) Serving JSON with the serveFile function
(
30:25) Serving images with the serveFile function
(
31:59) Sending a 404 status code
(
32:56) Logging requests and errors
(
35:51) Up and running with the web server
📚 References:
Node.js Official site: https://nodejs.org
NPM Official site: https://www.npmjs.com/
✅ Follow Me:
Twitter: https://twitter.com/yesdavidgray
LinkedIn: https://www.linkedin.com/in/davidagray/
Blog: https://yesdavidgray.com
Reddit: https://www.reddit.com/user/DaveOnEleven
Was this tutorial about how to build a web server with Node.js helpful? If so, please share. Let me know your thoughts in the comments.
#node #nodejs #server