Building web applications with Express.js
Express.js (https://expressjs.com/), or Express, has been and remains the most popular web framework for building web applications in Node.js. Express was one of the first Node.js web frameworks and was based on the Sinatra framework for Ruby on Rails. Express.js was a project of the OpenJS Foundation (https://openjsf.org/projects/), and previously the Node.js Foundation.
In this recipe, we will look at how to create an Express.js web server.
Getting ready
To get started, we'll create a folder named express-app
and initialize our project by running the following commands:
$ mkdir express-app $ cd express-app $ npm init --yes
How to do it
In this recipe, we'll create a web server that responds on the /
route using Express.js.
- First, let's start by installing the
express
module:$ npm install express
- Now, we need to create a few directories and files for our web application. While in your
express-app...