Skip to content

Instantly share code, notes, and snippets.

@rizafahmi
Last active May 26, 2018 05:27
Show Gist options
  • Save rizafahmi/c28778e1e7422708eabc5331390bdd83 to your computer and use it in GitHub Desktop.
Save rizafahmi/c28778e1e7422708eabc5331390bdd83 to your computer and use it in GitHub Desktop.
const express = require('express')
const path = require('path')
const app = express()
// View Engine setup
app.set('views', path.join(__dirname, 'templates'))
app.set('view engine', 'hbs')
app.use(express.static('public'))
app.get('/', function (req, resp) {
resp.render('index')
})
app.get('/about', function (req, resp) {
resp.send("Ini adalah workshop hacktiv8")
})
app.get('/echo/:name', function (req, resp) {
resp.render("index", {nama: req.params.name})
})
app.get('/hacktiv8', function (req, resp) {
resp.redirect("/about")
})
app.use(function (req, resp) {
console.log("Masuk ga ya?")
resp.status(404).send('Page not found')
})
app.listen(3000, function () {
console.log("server is running...")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment