Last active
May 26, 2018 05:27
-
-
Save rizafahmi/c28778e1e7422708eabc5331390bdd83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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