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.- Robust routing
- Focus on high performance
- Super-high test coverage
- HTTP helpers (redirection, caching, etc)
- View system supporting 14+ template engines
- Content negotiation
- Executable for generating applications quickly
How to install expressjs
$ npm install --save expressThe 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.
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