-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
43 lines (41 loc) · 1.31 KB
/
server.js
File metadata and controls
43 lines (41 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const express =require('express')
const app=express()
// app.use(date=(req,res,next)=>{
// let requistAt=new Date()
// console.log(requistAt)
// next()
// })
app.get('/',(req,res)=>{
const currentDate = new Date();
const hour = currentDate.getHours();
console.log('currentDate: ', currentDate)
console.log('hour: ', hour)
if (hour>=8 && hour<=17)
return(res.sendFile(__dirname+'/public/home.html'))
else
return(res.sendFile(__dirname+'/public/not-open.html'))
})
app.get('/contact',(req,res)=>{
const currentDate = new Date();
const hour = currentDate.getHours();
console.log('currentDate: ', currentDate)
console.log('hour: ', hour)
if (hour>=8 && hour<=17)
return(res.sendFile(__dirname+'/public/contact.html'))
else
return(res.sendFile(__dirname+'/public/not-open.html'))
})
app.get('/ourservices',(req,res)=>{
const currentDate = new Date();
const hour = currentDate.getHours();
console.log('currentDate: ', currentDate)
console.log('hour: ', hour)
if (hour>=8 && hour<=17)
return(res.sendFile(__dirname+'/public/ourservices.html'))
else
return(res.sendFile(__dirname+'/public/not-open.html'))
})
app.listen(3000,(error)=>{
if (error ) console.log("server not running on 3000")
else console.log("server running on 3000")
})