Posts

Showing posts with the label Web

Express.js Web Application

Image
Express.js Web Application: In this section, you will learn how to create a web application using Express.js. Express.js provides an easy way to create web server and render HTML pages for different HTTP requests by configuring routes for your application. Web Server: First of all, import the Express.js module and create the web server as shown below. app.js: Express.js Web Server var express = require( 'express' ); var app = express(); // define routes here.. var server = app.listen(5000, function () { console.log( 'Node server is running..' ); }); In the above example, we imported Express.js module using require() function. The express module returns a function. This function returns an object which can be used to configure Express application (app in the above example). The app object includes methods for routing HTTP requests, configuring middleware, rendering HTML views and registering a template engine. The app.listen() fun