From c4663dc58c4bbae758ac3766e6a801a3d7180b33 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 2 May 2021 22:11:05 +0200 Subject: Setting up html for pages and form body parser. --- index.js | 7 +++++++ views/home.handlebars | 14 +++++++++++++- views/new-post.handlebars | 13 ++++++++++++- 3 files changed, 32 insertions(+), 2 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.')); diff --git a/views/home.handlebars b/views/home.handlebars index c280c9d..02f31de 100644 --- a/views/home.handlebars +++ b/views/home.handlebars @@ -1,3 +1,15 @@
-

{{ title }}

+

Posts

+ +
+
+ Lorem ipsum dolor sit amet +
+
+
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. +
+
+
+
diff --git a/views/new-post.handlebars b/views/new-post.handlebars index c280c9d..19984ee 100644 --- a/views/new-post.handlebars +++ b/views/new-post.handlebars @@ -1,3 +1,14 @@
-

{{ title }}

+

{{ title }}

+
+
+ + +
+
+ + +
+ +
-- cgit v1.2.3