Created
September 15, 2018 05:00
-
-
Save davidnuon/4a4d5c6d8905ee89e075de729742480b to your computer and use it in GitHub Desktop.
A very serious gist
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
html | |
head | |
title= title | |
body | |
h1= 1970 | |
p Music was awful. |
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
html | |
head | |
title= title | |
body | |
h1= 1980 | |
p NEVER GOING TO GIVE YOU UP. |
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 pug = require('pug') | |
const app = express() | |
// Takes `data` and plugs it into a `templateName.html` to render it | |
// It's pug template | |
function getMarkup(templateName, data) { | |
pug.compileFile('./' + templateName + '.html')(data) | |
} | |
// Route at / | |
app.get('/', (req, res) => { | |
// We check for two query parameters | |
// Year: ?year=... | |
let year = req.query.year || 1970; | |
// WordPress Query String: ?wp=... | |
let wp = req.query.wp; | |
// Log it out debug | |
console.log(year, wp, req, res); | |
// Get the markup from getMarkup | |
// then send it out in a response | |
res.send(getMarkup(year.toString() ,{})); | |
}) | |
// Start that app at localhost:3000 | |
app.listen(3000, () => console.log('Example app listening on port 3000!')) |
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
{ | |
"name": "fur_leo", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"express": "^4.16.3", | |
"pug": "^2.0.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I put this in the public domain.