From 17b9fe4f2eeadcebc58290cbc63580901db6575c Mon Sep 17 00:00:00 2001 From: Onja Date: Tue, 10 Oct 2023 19:48:07 +0300 Subject: [PATCH] Add main layout template and index page template, and update the index route to render the index page with a form --- src/routes/index.js | 9 +++++++++ src/views/layout/main.hbs | 14 ++++++++++++++ src/views/pages/index.hbs | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/views/layout/main.hbs create mode 100644 src/views/pages/index.hbs diff --git a/src/routes/index.js b/src/routes/index.js index ed8581a..41c37af 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -2,9 +2,18 @@ var express = require('express'); var router = express.Router(); const FileService = require('../services/file'); +const TemplateService = require('../services/template'); + +const templateService = new TemplateService(); /* GET home page. */ router.get('/', async function(req, res, next) { + res.setHeader('Content-Type', 'text/html; charset=utf-8'); + res.send(templateService.renderPage('index', { title: 'Express' })); + return res; +}); + +router.post('/', async function(req, res, next) { // const url = 'https://bodacc-datadila.opendatasoft.com/api/explore/v2.1/catalog/datasets/annonces-commerciales/exports/csv?lang=fr&refine=publicationavis%3A%22A%22&refine=publicationavis_facette%3A%22Bodacc%20A%22&refine=familleavis_lib%3A%22Ventes%20et%20cessions%22&timezone=Asia%2FBaghdad&use_labels=true&delimiter=%3B'; const url = 'https://bodacc-datadila.opendatasoft.com/api/explore/v2.1/catalog/datasets/annonces-commerciales/exports/csv?lang=fr&refine=publicationavis%3A%22A%22&refine=publicationavis_facette%3A%22Bodacc%20A%22&refine=familleavis_lib%3A%22Ventes%20et%20cessions%22&refine=numerodepartement%3A%2275%22&refine=typeavis_lib%3A%22Avis%20d%E2%80%99annulation%22&timezone=Asia%2FBaghdad&use_labels=true&delimiter=%3B'; diff --git a/src/views/layout/main.hbs b/src/views/layout/main.hbs new file mode 100644 index 0000000..313ccb5 --- /dev/null +++ b/src/views/layout/main.hbs @@ -0,0 +1,14 @@ + + + + + Example App + + + + +
+ {{{body}}} +
+ + \ No newline at end of file diff --git a/src/views/pages/index.hbs b/src/views/pages/index.hbs new file mode 100644 index 0000000..e535166 --- /dev/null +++ b/src/views/pages/index.hbs @@ -0,0 +1,37 @@ +
+
+ +

Hello world

+ +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
\ No newline at end of file