Created
January 26, 2019 04:12
-
-
Save LuisOsta/4baa0bc8d9ed0e8ac4c57223cc393001 to your computer and use it in GitHub Desktop.
updated header.hbs
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 express = require("express"); | |
const path = require("path"); | |
const hbs = require("hbs"); | |
const app = express(); | |
let PORT = 8080; | |
const publicPath = path.join(__dirname, "../../public"); | |
app.use(express.static(publicPath)); | |
// setups hbs view path, where express will look for files | |
const partialPath = path.join(__dirname, "../views/partials"); | |
const viewPath = path.join(__dirname, "../views"); | |
// configures express to use hbs | |
hbs.registerPartials(partialPath); | |
app.set("view engine", "hbs"); | |
app.set("views", viewPath); | |
// base url for homepage | |
app.get("/", (req, res) => { | |
console.log("RENDERING THE HOME PAGE"); | |
res.render("home.hbs"); // express looks for a file in the views directory, | |
//then compiles and renders them to the client | |
}); | |
app.get('/about', (req, res) => { | |
console.log("RENDERING THE ABOUT PAGE") | |
res.render("about.hbs") | |
}) | |
app.get('/more', (req, res) => { | |
console.log("RENDERING THE MORE PAGE") | |
res.render("more.hbs") | |
}) | |
app.listen(PORT, () => { | |
console.log(`Server is up on port ${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment