Video 47: Dynamic Pages with Templating
This commit is contained in:
@@ -4,8 +4,29 @@ const express = require('express')
|
||||
const app = express()
|
||||
const publicDirectoryPath = path.join(__dirname, '../public')
|
||||
|
||||
app.set('view engine', 'hbs')
|
||||
app.use(express.static(publicDirectoryPath))
|
||||
|
||||
app.get('', (req, res) => {
|
||||
res.render('index', {
|
||||
title: 'Weather App',
|
||||
name: 'Jason Williams'
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/about', (req, res) => {
|
||||
res.render('about', {
|
||||
title: 'About Me',
|
||||
name: 'Jason Williams'
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/help', (req, res) => {
|
||||
res.render('help', {
|
||||
helpText: 'This is some helpful text.'
|
||||
})
|
||||
})
|
||||
|
||||
app.get('/weather', (req, res) => {
|
||||
res.send({
|
||||
forecast: 'It is snowing. In September.',
|
||||
|
||||
Reference in New Issue
Block a user