-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (29 loc) · 674 Bytes
/
app.js
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
const express=require('express'),
ejs =require('ejs');
var app=express();
app.set('view engine','ejs');
app.use(express.static(__dirname+'/public'));
// app.get('/',function(req,res){
// })
//same as above code
app.get('/',(req,res)=>{
res.render('index',{
welcomeMessage:'hello welcome to our webpage',
pageTitle:'About Page',
currentYear:new Date().getFullYear()
})
});
app.get('/about',(req,res)=>{
res.render('about',{
pageTitle:'About Page',
currentYear:new Date().getFullYear()
});
});
app.get('/bad',(req,res)=>{
res.send({
message:'something went wrong'
});
});
app.listen(3000,(req,res)=>{
console.log('serving to your request');
})