Lesson 4. Building a simple web server in Node.js

 

This lesson covers some basic functions of the http module, a Node.js library of code used for handling requests over the internet. The tech community raves about Node.js and its use of JavaScript as a server-side language. In this lesson, you build your first web server. In a few short steps, you convert a couple of lines of JavaScript to an application with which you can communicate on your web browser.

This lesson covers

  • Generating a basic web server using Node.js and npm
  • Writing code that processes requests from a browser and sends back a response
  • Running a web server in your browser
Consider this

You’re on your way to building your first web application. Before you deliver a complete application, the cooking community would like to see a simple site with the flexibility to improve and add features in the future. How long do you think it will take you to build a prototype?

With Node.js, you can use the http module to get a web server with sufficient functionality built within hours.

4.1. Understanding web servers

Web servers are the foundation of most Node.js web applications. They allow you to load images and HTML web pages to users of your app. Before you get started, I’ll discuss some important web server concepts. After all, the final product will look and feel a lot better if you have clear expectations of the result.

4.2. Initializing the application with npm

4.3. Coding the application

4.4. Running the application

Summary

sitemap