Express
π₯Express is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications. It facilitates the rapid development of Node based Web applications.
π₯Following are some of the core features of Express framework β
- Allows to set up middle wares to respond to HTTP Requests.
- Defines a routing table which is used to perform different actions based on HTTP Method and URL.
- Allows to dynamically render HTML Pages based on passing arguments to templates.
π₯Install the Express framework globally using NPM so that it can be used to create a web application using node terminal.
npm install express --save
π₯we should install the following important modules along with express
- body-parser β This is a node.js middleware for handling JSON, Raw, Text and URL encoded form data.
npm install body-parser --save
- cookie-parser β Parse Cookie header and populate req.cookies with an object keyed by the cookie names.
npm install cookie-parser --save
- multer β This is a node.js middleware for handling multipart/form-data.
npm install multer --save
π₯Request & Response
Express application uses a callback function whose parameters are request and response objects.app.get('/',function()
{
})
- Request Object
β The request object represents the HTTP request and has properties
for the request query string, parameters, body, HTTP headers.
- Response Object β The response object represents the HTTP response that an Express app sends when it gets an HTTP request.
No comments:
Post a Comment