Defining Routes with Express JS for your App

$ node -v
$ mkdir project-name
$ cd project-name
$ npm init //I accepted all the default values by pressing enter
$ npm install express --save
const express = require('express')
const app = express()
app.get('/', function (req, res) {
res.send('Home Page')
})
app.get('/page1', function (req, res) {
res.send('page1')
})
app.listen(3000)
$ node index.js
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
http://localhost:3000/http://localhost:3000/page1

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store