Node.js - Express Framework
Express is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications.
Features of Express framework :
- Allows to dynamically render HTML Pages based on passing arguments to templates.
- Defines a routing table which is used to perform different actions based on HTTP Method and URL.
- Allows to set up middle-wares to respond to HTTP Requests.
To work with Express first we have Install Express framework
NPM so that it can be used to create a web application using node terminal.npm install express
We should install the following important modules along with express
1. Body parser
- This is a node.js middleware for handling JSON, Raw, Text and URL encoded form data
- npm install body-parser
2.Cookie parser
- Parse Cookie header and populate req.cookies with an object keyed by the cookie names
- npm install cookie-parser
3.Multer
- This is a node.js middleware for handling multipart/form-data.
- npm install multer
How we use express in our files is, we have to call that
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World');
})
var server = app.listen(8081, function () {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
})
Example app listening at http://0.0.0.0:8081
Thanks for sharing information..
ReplyDeletereact js training in hyderabad