Skip to content

Instantly share code, notes, and snippets.

@gaurangrshah
Created January 16, 2019 04:13
Show Gist options
  • Save gaurangrshah/67705ab1a24ab54b5ac2b532720cfe07 to your computer and use it in GitHub Desktop.
Save gaurangrshah/67705ab1a24ab54b5ac2b532720cfe07 to your computer and use it in GitHub Desktop.
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