-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (22 loc) · 805 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
const express = require('express');
const app = express();
const port = 5000
// Making public folder to static and used directly from browser.
app.use(express.static('public'));
//app.use(express.static('src/views'));
app.set('views', './src/views');
//app.set('view engine', 'jade');
const handlebars = require('express-handlebars');
app.engine('.hbs', handlebars({extname: '.hbs'}))
app.set('view engine', '.hbs');
app.get('/', (req, res) => {
// {list: ['a', 'b', 'c']}, this is behave like locasls(Rails)
// We will directly access `list` variable in `index` template
res.render("index", {title: 'Hello from render',list: ['a', 'b', 'c']});
});
app.get('/books', (req, res) => {
res .send("Hello Books!!");
});
app.listen(port, (err) => {
console.log('Running server on port ' + port);
});