The app.use() function is used to mount the specified middleware function(s) at the path which is being specified. It is mostly used to set up middleware for your application.
- path: It is the path for which the middleware function is being called. It can be a string representing a path or path pattern or regular expression pattern to match the paths.
- callback: It is a middleware function or a series/array of middleware functions.
Installation of express module:
- You can visit the link to Install express module. You can install this package by using this command.
npm install express
- After installing express module, you can check your express version in command prompt using the command.
npm version express
- After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.
Steps to run the program:
- The project structure will look like this:
- Make sure you have installed express module using the following command:
npm install express
- Run index.js file using below command:
Server listening on PORT 3000
Now open your browser and go to http://localhost:3000/user and you can see the following output on console as shown below:
Server listening on PORT 3000 Middleware called /user request called
And on browser you will see the Welcome to GeeksforGeeks.
- Scaffolding an ExpressJS app from scratch
- Routing Path for ExpressJS
- HandleBars Templating in ExpressJS
- How to get the function name inside a function in PHP ?
- PHP | cos( ) Function
- PHP | abs() Function
- PHP | Ds\Set contains() Function
- PHP | sin( ) Function
- PHP | Ds\Set xor() Function
- D3.js | d3.max() function
- D3.js | d3.lab() Function
- PHP | Ds\Map put() Function
- D3.js | d3.hcl() Function
- PHP | dir() Function
- D3.js now() function
- PHP | ord() Function
- PHP | Ds\Set add() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.