Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 1044 of 3366
3K+ Views
The app.set() function assigns or sets a setting name to value. This can store any type of value as the user wants, but there are some certain names that can be used to configure the behaviour of the serverSome of the properties that can be configured with the set functionality are −envetagjsonp escape, etcSyntaxapp.set(name, value)Example 1Create a file with the name "appSet.js" and copy the following code snippet. After creating the file, use the command "node appSet.js" to run this code.// app.set() Demo Example // Importing the express module var express = require('express'); // Initializing the express and ... Read More
1K+ Views
The app.route() method returns the instance of a single route. This single route can be used to handle the HTTP verbs with the optional middleware. This method is mainly used to avoid duplicate names.Syntaxapp.route( )Example 1Create a file with the name "appRoute.js" and copy the following code snippet. After creating the file, use the command "node appRoute.js" to run this code.// app.route() Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); var PORT = 3000; // Creating a get, post & other requests app.route('/user') ... Read More
2K+ Views
The app.render() method is used for returning the rendered HTML of a view using the callback function. This method accepts an optional parameter that is an object which contains the local variables for the view.This method is similar to the res.render() function with the difference that it cannot send the rendered view to the client/user itself.Syntaxapp.render(view, [locals], callback)ExampleCreate a file with the name "appRender.js" and copy the following code snippet. After creating the file, use the command "node appRender.js" to run this code.// app.render() Method Demo Example // Importing the express module const express = require('express'); // Initializing ... Read More
8K+ Views
The app.post() method routes all the HTTP POST requests to the specified path with the specified callback functions.Syntaxapp.path(path, callback, [callback])Parameterspath − This is the path for which the middleware function is invoked. A path can be a string, path pattern, a regular expression or an array of all these.callback − These are the middleware functions or a series of middleware functions that acts like a middleware except that these callbacks can invoke next (route).Example 1Create a file with the name "appPost.js" and copy the following code snippet. After creating the file, use the command "node appPost.js" to run this code.// ... Read More
676 Views
The app.path() method returns the canonical path. The path is returned as a string. It is better to use the req.baseUrl method since the app.path() method can be very complicated in complex cases of mounted apps.Syntaxapp.path( )Example 1Create a file with the name "appPath.js" and copy the following code snippet. After creating the file, use the command "node appPath.js" to run this code.// app.path() Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); var PORT = 3000; // Assigning express constructor var app = ... Read More
1K+ Views
The app.param() method is basically used for adding the callback triggers to the route parameters, where name represents the name of the parameter or an array of them and callback represents the callback function.Syntaxapp.param([name], callback)Parametersname − Represents the name of the parameter or array of parameters as required.callback − Represents the callback function. The parameters of the callback function include the request object, the response object, the next middleware, the value of the parameter, and the name of the parameter in the same order.ExampleCreate a file with the name "appParam.js" and copy the following code snippet. After creating the file, ... Read More
529 Views
The app.mountpath property contains those path patterns on which a sub-app was mounted. A sub-app can be defined as an instance of Express that may be used for handling the request to a route.This property is similar to the baseUrl property of the req object; the only difference is that req.baseUrl returns the matched URL path instead of the matched patterns.Syntaxapp.mountpathExample 1Create a file "appMountpath.js" and copy the following code snippet. After creating the file, use the command "node appMountpath" to run this code.// app.mountpath code Demo Example // Importing the express module var express = require('express'); // ... Read More
1K+ Views
The app.locals object defines the properties that are local variables inside an application. Once the value of app.locals property is set, it persists throughout the life of the application. The res.locals property is valid only for the lifetime of the request.Syntaxapp.localsExample 1Create a file "appLocals.js" and copy the following code snippet. After creating the file, use the command "node appLocals.js" to run this code.// app.locals code Demo Example // Importing the express module var express = require('express'); // Initializing the express and port number var app = express(); // Setting the below email throught out the application ... Read More
8K+ Views
The app.listen() method binds itself with the specified host and port to bind and listen for any connections. If the port is not defined or 0, an arbitrary unused port will be assigned by the operating system that is mainly used for automated tasks like testing, etc.The app object returned by express() is a JavaScript function, that is passed to Node’s HTTP servers as a callback which handles the requests. This makes the application to provide both HTTP and HTTPS versions of the same app with the same code base, as the app does not inherit from these.Syntaxapp.listen([port], [host], [backlog], ... Read More
1K+ Views
We can plot Line Graph, Pie Chart, Histogram, etc. with a Pandas DataFrame using Matplotlib. For this, we need to import Pandas and Matplotlib libraries −import pandas as pd import matplotlib.pyplot as pltLet us begin plotting −Line GraphExampleFollowing is the code −import pandas as pd import matplotlib.pyplot as plt # creating a DataFrame with 2 columns dataFrame = pd.DataFrame( { "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'], "Reg_Price": [2000, 2500, 2800, 3000, 3200, 3500], "Units": [100, 120, 150, 170, 180, 200] ... Read More