SHARE
TWEET

Untitled

a guest Aug 24th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express')
  2. var app = express()
  3.  
  4. var requestTime = function (req, res, next) {
  5.   req.requestTime = new Date().toLocaleString()
  6.   next()
  7. }
  8.  
  9.  
  10.  
  11. app.get('/', requestTime, (req, res)=> {
  12.   var responseText = 'Hello World!<br>'
  13.   responseText += 'Requested at: ' + req.requestTime
  14.   res.send(responseText)
  15. })
  16.  
  17. app.get('/someother',(req,res)=>{
  18. res.send("Hello World")
  19.  
  20. })
  21.  
  22. app.listen(3000)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top