Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JadePrototypePullotionApp
const express = require('express');
const path = require('path');
const app = express();
var router = express.Router();
app.set('views', path.join(__dirname, 'views'));
app.engine('jade', require('jade').__express);
app.set("view engine", "jade");
app.use(express.json()).use(express.urlencoded({
extended: false
}));
const isObject = obj => obj && obj.constructor && obj.constructor === Object;
const merge = (a, b) => {
for (var attr in b) {
if (isObject(a[attr]) && isObject(b[attr])) {
merge(a[attr], b[attr]);
} else {
a[attr] = b[attr];
}
}
return a
}
const clone = (a) => {
return merge({}, a);
}
router.get('/', (req, res, next) => {
res.render('index', {
title: 'HTML',
name: ''
});
});
router.post('/', (req, res, next) => {
var body = JSON.parse(JSON.stringify(req.body));
var copybody = clone(body)
res.render('index', {
title: 'HTML',
name: copybody.name || ''
});
});
app.use('/', router)
app.listen(3000, () => console.log('Example app listening on port http://127.0.0.1:3000 !'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.