
- MEAN.JS Tutorial
- MEAN.JS - Home
- MEAN.JS - Overview
- MEAN.JS - Architecture
- Build Node Web App
- MEAN.JS - Mean Project Setup
- Building Static Route Node Express
- MEAN.JS - Build Data Model
- MEAN.JS - REST API
- Front End with Angular
- Angular Components in App
- Building Single Page with Angular
- Building an SPA: The next level
- MEAN.JS Useful Resources
- MEAN.JS - Quick Guide
- MEAN.JS - Useful Resources
- MEAN.JS - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MEAN.JS - Building Static Route Node Express
This chapter demonstrates building route for an application with Node and Express.
In the previous chapter, we created a node-express application. Navigate to project directory called mean-demo. Go to the directory by using below command −
$ cd mean-demo
Setting Up Routes
Routes are used as mapping service by using URL of an incoming request. Open the server.js file and setup the routing as shown below −
// modules ================================================= const express = require('express'); const app = express(); // set our port const port = 3000; app.get('/', (req, res) ⇒ res.send('Welcome to Tutorialspoint!')); //defining route app.get('/tproute', function (req, res) { res.send('This is routing for the application developed using Node and Express...'); }); // startup our app at http://localhost:3000 app.listen(port, () ⇒ console.log(`Example app listening on port ${port}!`));
Running Application
Next, run the application with the below command −
$ npm start
You will get a confirmation as shown in the image below −

Now, go to browser and type http://localhost:3000/myroute. You will get the page as shown in the image below −

Advertisements