-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
45 lines (38 loc) · 958 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
35
36
37
38
39
40
41
42
43
44
45
const express = require('express')
const app = express()
const port = 30000
const handlebars = require('express-handlebars')
const {engine} = require('express-handlebars')
fruits = () => {
return [{
'name': 'apple',
'color': 'green'
}, {
'name': 'lime',
'color': 'green'
}, {
'name': 'banana',
'color': 'yellow'
}, {
'name': 'peach',
'color': 'orange'
}, {
'name': 'plume',
'color': 'purple'
}, {
'name': 'blueberry',
'color': 'purple'
},]
}
app.engine('handlebars', engine({
layoutsDir: __dirname + '/views/layouts',
defaultLayout: 'index'
}))
app.set('view engine', 'handlebars')
app.use(express.static('public'))
app.get('/', (req, res) => {
res.render('main', {'fruit_basket': fruits(), basket: true})
})
app.listen(port, () => {
console.log(`App is listens to port ${port} on http://localhost:${port}`)
})