Created
January 16, 2019 04:13
-
-
Save gaurangrshah/67705ab1a24ab54b5ac2b532720cfe07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
// run: npm install express | |
const app = express(); | |
// adding handling for browser's get request: | |
app.get('/', function(req, res) { | |
res.send('<h1>Hello, world</h1>'); | |
// handling get request and responding with "hello" | |
}); | |
app.get('/about', function (req,res) { | |
res.send('<h1>About</h1>'); | |
}); | |
app.get('/hobbies', function (req,res) { | |
res.send('<h1>Hobbies</h1>'); | |
}); | |
app.get('/contact', function (req,res) { | |
res.send('<h1>Contact</h1>'); | |
}); | |
app.listen(3000, function() { | |
console.log('server has started on port 3000'); | |
// using a callback func. to log our console msg | |
// once the server starts | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment