-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (32 loc) · 866 Bytes
/
app.js
File metadata and controls
41 lines (32 loc) · 866 Bytes
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
//require packages used in the project
const express = require('express')
const app = express()
const port = 3000
//require express-handlebars here
const exphbs = require('express-handlebars')
//setting template engine
app.engine('handlebars',exphbs({defaultLayout: 'main'}))
app.set('view engine', 'handlebars')
//setting static file
app.use(express.static('public'))
//routes setting
app.get('/',(req,res) => {
console.log('req', req)
res.render(`index`)
})
app.get('/about', (req, res) => {
console.log('req', req)
res.render(`about`)
})
app.get('/portfolio', (req, res) => {
console.log('req', req)
res.render(`portfolio`)
})
app.get('/contact', (req, res) => {
console.log('req', req)
res.render(`contact`)
})
//start and listen on the Express server
app.listen(port,() => {
console.log(`Express is listening on localhost:${port}`)
})