-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 832 Bytes
/
Copy pathindex.js
File metadata and controls
29 lines (23 loc) · 832 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
const express = require('express');
const path = require('path');
const exphbs = require('express-handlebars');
const app = express();
const port = 3000;
// Create the handlebars engine instance
const hbs = exphbs.create({
defaultLayout: 'main', // Default layout if you use one
extname: '.handlebars',
layoutsDir: path.join(__dirname, 'views/layouts'),
});
// Set up handlebars as the view engine
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
app.set('views', path.join(__dirname, 'views')); // Set views directory
// Serve static files
app.use(express.static(path.join(__dirname, 'static')));
// Routes
app.use('/', require(path.join(__dirname, 'routes/blog.js')));
// Start the server
app.listen(port, () => {
console.log(`Blog app listening at http://localhost:${port}`);
});