-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
48 lines (40 loc) · 996 Bytes
/
server.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var express = require("express")
var app = express()
const pdf = require("./routes/pdf.routes")
app.set("view engine", 'ejs')
const posts = [
{ title: 'Title 1', body: 'Body 1' },
{ title: 'Title 2', body: 'Body 2' },
{ title: 'Title 3', body: 'Body 3' },
{ title: 'Title 4', body: 'Body 4' },
]
const user = {
firstName: 'Suneel',
lastName: 'Kumar',
}
app.get("/", function (req, res) {
res.render('pages/index', {
user,
title: "Home Page"
})
// res.render('pages/index')
});
app.get('/articles', (req, res) => {
res.render('pages/articles', {
articles: posts,
title: "Articles"
})
})
app.get('/about', function (req, res) {
res.render('pages/about', {
title: "About"
})
})
// app.get('/pages/pdf/edit', function (req, res) {
// res.render('pages/pdf/edit', {
// title: "PDF"
// })
// })
app.use('/pages/pdf', pdf)
app.listen(3000)
console.log("Server is listening on port 3000")