aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-05-02 22:11:05 +0200
committerMateja <mail@matejamaric.com>2021-05-02 22:11:05 +0200
commitc4663dc58c4bbae758ac3766e6a801a3d7180b33 (patch)
tree91fb84516fa0534cd93efb5d52d2f8d63d9b0d00 /index.js
parent7483bb5da6b22b94045a309d2ece2ed80ce48dc2 (diff)
downloadnode-playground-c4663dc58c4bbae758ac3766e6a801a3d7180b33.tar.gz
node-playground-c4663dc58c4bbae758ac3766e6a801a3d7180b33.zip
Setting up html for pages and form body parser.
Diffstat (limited to 'index.js')
-rw-r--r--index.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/index.js b/index.js
index 9866dde..81e84a3 100644
--- a/index.js
+++ b/index.js
@@ -8,6 +8,8 @@ app.set('view engine', 'handlebars');
app.use(express.static('public'));
+app.use(express.urlencoded({extended: false}));
+
app.get('/', (req, res) => {
res.render('home', {
title: 'Home Page',
@@ -22,4 +24,9 @@ app.get('/new-post', (req, res) => {
});
});
+app.post('/new-post', (req, res) => {
+ console.log(req.body);
+ res.redirect('/');
+});
+
app.listen(8080, () => console.log('Server started on port 8080.'));