aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2021-05-02 23:32:40 +0200
committerMateja <mail@matejamaric.com>2021-05-02 23:32:40 +0200
commitc2649bfff51a175508685e493d8bfae4713cda16 (patch)
treee4295e36c537a6eaa3930c0f3dcf2cf292d9b0fb /routes
parentc4663dc58c4bbae758ac3766e6a801a3d7180b33 (diff)
downloadnode-playground-c2649bfff51a175508685e493d8bfae4713cda16.tar.gz
node-playground-c2649bfff51a175508685e493d8bfae4713cda16.zip
Started using Express router.
Diffstat (limited to 'routes')
-rw-r--r--routes/web.js23
1 files changed, 23 insertions, 0 deletions
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;