Created
June 20, 2021 19:08
-
-
Save code08-ind/c1e696b63c8370a4f3a2d30abe43ed42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const express = require('express'); | |
const hbs = require('hbs'); | |
const app = express(); | |
const port = 8000; | |
const localHost = '127.0.0.1'; | |
const staticPath = path.join(__dirname, '../public'); | |
const viewsPath = path.join(__dirname, '../views'); | |
app.use(express.static(staticPath)); | |
app.set('view engine', 'hbs'); | |
app.set('views', viewsPath); | |
app.get('/', (req, res) => { | |
res.render('Home', { title: "Home Page" }); | |
}); | |
app.get('/about', (req, res) => { | |
res.render('About', { title: "About Page" }); | |
}); | |
app.get('/*', (req, res) => { | |
res.render('Error', { title: "Error Page" }); | |
}); | |
app.listen(port, localHost, () => { | |
console.log(`Server Listening At Port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment