Skip to content

Instantly share code, notes, and snippets.

@adityajoshi12
Created August 12, 2019 13:34
Show Gist options
  • Save adityajoshi12/4cdd4bdef2c22dc32d065da279fe943c to your computer and use it in GitHub Desktop.
Save adityajoshi12/4cdd4bdef2c22dc32d065da279fe943c to your computer and use it in GitHub Desktop.
var express = require('express')
var app = express()
var requestTime = function (req, res, next) {
req.requestTime = new Date().toLocaleString()
next()
}
app.get('/', requestTime, (req, res)=> {
var responseText = 'Hello World!<br>'
responseText += 'Requested at: ' + req.requestTime
res.send(responseText)
})
app.get('/someother',(req,res)=>{
res.send("Hello World")
})
app.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment