Node js with express framework

Leave a Comment

What is express

Express is node js web application framework which provide set of feature to develop web and mobile applications. It provides following features.

  1. Robust routing
  2. Focus on high performance
  3. Super-high test coverage
  4. HTTP helpers (redirection, caching, etc)
  5. View system supporting 14+ template engines
  6. Content negotiation
  7. Executable for generating applications quickly

How to install expressjs

$ npm install --save express
The above command saves the installation locally in the node_modules directory and creates a directory express inside node_modules.

Hello world in express js

var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.send('Hello World From express!')
})

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})
Save above file as app.js.The app starts a server and listens on port 3000 for connections. The app responds with “Hello World From express!” for requests to the root URL (/) or route. For every other path, it will respond with a 404 Not Found.
Run the app with the following command:
$ node app.js

Then, load http://localhost:3000/ in a browser to see the output.


Hello world in express js


Please comment down below if you have any query and please follows us for more awesome tutorials and keep motivating us .

0 comments:

Post a Comment

Powered by Blogger.