From c2649bfff51a175508685e493d8bfae4713cda16 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 2 May 2021 23:32:40 +0200 Subject: Started using Express router. --- routes/web.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 routes/web.js (limited to 'routes') diff --git a/routes/web.js b/routes/web.js new file mode 100644 index 0000000..a1a7b01 --- /dev/null +++ b/routes/web.js @@ -0,0 +1,23 @@ +const express = require('express'); +const router = express.Router(); + +router.get('/', (req, res) => { + res.render('home', { + title: 'Home Page', + home: true + }); +}); + +router.get('/new-post', (req, res) => { + res.render('new-post', { + title: 'Make A New Post', + newPost: true + }); +}); + +router.post('/new-post', (req, res) => { + console.log(req.body); + res.redirect('/'); +}); + +module.exports = router; -- cgit v1.2.3