Skip to content

Instantly share code, notes, and snippets.

@kunxin-chor
Created July 22, 2021 11:25
Show Gist options
  • Save kunxin-chor/487fb53e18f7ab659e4811b9a843f056 to your computer and use it in GitHub Desktop.
Save kunxin-chor/487fb53e18f7ab659e4811b9a843f056 to your computer and use it in GitHub Desktop.
Express Template
// import in the packages
const express = require('express');
const hbs = require('hbs');
const wax = require('wax-on')
let app = express();
app.set('view engine', 'hbs');
// Inform Express where to find static images, css and
// client-side (ie. browser)
app.use(express.static('public'))
// Setup Wax On (for templates with HBS)
wax.on(hbs.handlebars);
wax.setLayoutPath('./views/layouts')
// enable forms
app.use( express.urlencoded({
'extended': false
}))
// ROUTES
app.get('/', function(req,res){
res.send("Hello world");
})
// START SERVER
app.listen(3000, function(req,res){
console.log("Server started")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment