Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

What is Express.js

Express is a fast, assertive, essential and moderate web framework of Node.js. You can assume express as a layer built on the top of the Node.js that helps manage a server and routes. It provides a robust set of features to develop web and mobile applications.

Let’s see some of the core features of Express framework:

  • It can be used to design single-page, multi-page and hybrid web applications.
  • It allows to setup middlewares to respond to HTTP Requests.
  • It defines a routing table which is used to perform different actions based on HTTP method and URL.
  • It allows to dynamically render HTML Pages based on passing arguments to templates.

Why use Express

  • Ultra fast I/O
  • Asynchronous and single threaded
  • MVC like structure
  • Robust API makes routing easy

How does Express look like

Let’s see a basic Express.js app.

File: basic_express.js

  1. var express = require(‘express’);
  2. var app = express();
  3. app.get(‘/’, function (req, res) {
  4.   res.send(‘Welcome to Kreationnext!’);
  5. });
  6. var server = app.listen(8000, function () {
  7.   var host = server.address().address;
  8.   var port = server.address().port;
  9.   console.log(‘Example app listening at http://%s:%s’, host, port);
  10. });