diff --git a/app.js b/app.js index 77bb4b7..b6ca8d8 100644 --- a/app.js +++ b/app.js @@ -10,6 +10,9 @@ const randomRouter = require("./routes/random"); app.use('/random/:type', randomRouter); app.use('/', indexRouter); +app.set("view engine", "pug"); +app.set("views", path.join(__dirname, "public")); + app.use(function (req, res, next) { res.sendStatus(404); }); diff --git a/public/home.pug b/public/home.pug new file mode 100644 index 0000000..da005e6 --- /dev/null +++ b/public/home.pug @@ -0,0 +1,6 @@ +html + head + title= 'Home Page' + body + h1= message + p= from diff --git a/routes/index.js b/routes/index.js index c1da291..e5cca26 100644 --- a/routes/index.js +++ b/routes/index.js @@ -6,4 +6,12 @@ router.get('/', function(req, res, next) { res.sendFile(path.join(__dirname, '../public/index.html')); }); +router.get('/home', (req, res) => { + const context = { + message:'You are in the home page', + from:'user'} + + res.render('home', context); +}); + module.exports = router;