The main goal is stated in the title of the article. It is done after creating a web-based application using express framework as shown in the article titled ‘How to Check to Package Dependencies in Web-based Application powered by Express Framework using npm’ in this link. The folder which contains files needed for a simple default page can be presented or can be displayed in a web browser is already created. So, the remaining things to be done is adding line for the app can be presented or can be displayed in a web browser. The steps taken to accomplish the task is shown as follows :
1. Add the following line into the file named app.js :
The line of script means that the application executed will start listen in port 3000. So, if there is any request further directed to that port, the application will serve and response the request.
2. Just start the application by using the command tool ‘node’. Below is the actual pattern of the command tool execution :
user@hostname:~/nodejs/test$ node app.js GET / 200 676ms - 170b GET /stylesheets/style.css 200 17ms - 110b
So, by executing the above command, node is actually serving itself to listen in to the port specified in the app.js file which is in the port 3000. So, every request send directly to port 3000 will be served by node and the response will be given back. The following is the output of the request made in the web browser :
As shown in the above output, there is something printed in the page which is indicating the web-page powered by Express framework.