29 lines
688 B
JavaScript
29 lines
688 B
JavaScript
const express = require('express')
|
|
const app = express()
|
|
const port = 3003
|
|
const serveIndex = require('serve-index')
|
|
const {engine} = require('express-handlebars')
|
|
const indexRouter = require('./src/router/indexRouter')
|
|
|
|
const publicPath = "/public"
|
|
const inUrlPath = "public"
|
|
|
|
|
|
app.engine('.hbs', engine({extname: '.hbs', helpers: {
|
|
ifDivisibleBy: function (index, divisor, options) {
|
|
if (index % divisor === 0) {
|
|
return options.fn(this);
|
|
}
|
|
}
|
|
}}));
|
|
app.set('view engine', '.hbs');
|
|
|
|
app.use(publicPath, express.static(inUrlPath), serveIndex(inUrlPath, {
|
|
icons: true
|
|
}))
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Listening on port ${port}`)
|
|
})
|
|
|
|
app.use('/', indexRouter) |