-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (31 loc) · 674 Bytes
/
index.js
File metadata and controls
38 lines (31 loc) · 674 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
var express = require('express');
var app = express();
var exphbs = require('express-handlebars');
app.use(express.static('public'));
app.engine('.hbs', exphbs({
extname : '.hbs',
defaultLayout : 'main'
}));
app.set('view engine', '.hbs');
var productsRouter = require('./products');
app.use('/products', productsRouter);
app.get('/', function(req, res) {
// res.send('Hello World!');
var products = [
{
title : 'Product One',
price : 1000
},
{
title : 'Product Two',
price : 1000
}
];
res.render('home', {
title : 'Home Page',
products : products
});
});
app.listen(3000, function() {
console.log('start listening on port 3000!');
});