From a2d9baf6e79345bd65013db3c8cbb5e755685628 Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Mon, 30 Sep 2019 11:50:05 -0600 Subject: [PATCH] Video 48: Customizing the Views Directory --- web-server/src/app.js | 9 ++++++++- web-server/{views => templates}/about.hbs | 0 web-server/{views => templates}/help.hbs | 0 web-server/{views => templates}/index.hbs | 0 4 files changed, 8 insertions(+), 1 deletion(-) rename web-server/{views => templates}/about.hbs (100%) rename web-server/{views => templates}/help.hbs (100%) rename web-server/{views => templates}/index.hbs (100%) diff --git a/web-server/src/app.js b/web-server/src/app.js index 2887b36..b9ec236 100644 --- a/web-server/src/app.js +++ b/web-server/src/app.js @@ -2,9 +2,16 @@ const path = require('path') const express = require('express') const app = express() -const publicDirectoryPath = path.join(__dirname, '../public') +// Define paths for Express config +const publicDirectoryPath = path.join(__dirname, '../public') +const viewsPath = path.join(__dirname, '../templates') + +// Setup handlebars engine and views location app.set('view engine', 'hbs') +app.set('views', viewsPath) + +// Setup static directory to serve app.use(express.static(publicDirectoryPath)) app.get('', (req, res) => { diff --git a/web-server/views/about.hbs b/web-server/templates/about.hbs similarity index 100% rename from web-server/views/about.hbs rename to web-server/templates/about.hbs diff --git a/web-server/views/help.hbs b/web-server/templates/help.hbs similarity index 100% rename from web-server/views/help.hbs rename to web-server/templates/help.hbs diff --git a/web-server/views/index.hbs b/web-server/templates/index.hbs similarity index 100% rename from web-server/views/index.hbs rename to web-server/templates/index.hbs