-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (26 loc) · 1.02 KB
/
app.js
File metadata and controls
34 lines (26 loc) · 1.02 KB
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
const http = require('http');
const path = require('path');
const bodyParser = require('body-parser');
const express = require('express');
const adminData = require('./routes/admin');
const shopRoutes = require('./routes/shop');
const expressHbs = require('express-handlebars');
const app = express();
// app.engine('handlebars', expressHbs({
// layoutsDir: 'views/layouts/',
// defaultLayout: 'main-layout',
// extname : 'handlebars'
// }));//in case of using handlebars
// app.set('view engine', 'handlebars');//in case of using handlebars
// app.set('view engine', 'pug');//in case of using pug
app.set('view engine', 'ejs');
app.set('views', 'views');
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static(path.join(__dirname, 'public')))
app.use('/admin', adminData.routes);
app.use(shopRoutes);
app.use((req, res,next) => {
res.status(404).render('404', {pageTitle: 'Page Not Found', path: 'notFound'});
//res.status(404).sendFile(path.join(__dirname, 'views', '404.html'));
})
app.listen(3000);