forked from ryerson-ggl/tutorial-express-leaflet
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (20 loc) · 888 Bytes
/
index.js
File metadata and controls
26 lines (20 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var express = require('express');
var router = express.Router();
// dependencies that will be needed.
const fs = require('fs');
// doing a syncronous reading of the file in order to "load the data" after that async can be used for a better user experience.
let geoJSON_data = fs.readFileSync('Restaurant_data.geojson');
let Restaurants = JSON.parse(geoJSON_data);
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express - Leaflet' }); // refers to index.pug
});
router.get('/restaurants', function(req,res, next){
res.render('index2', {datastr: JSON.stringify(Restaurants)});
// res.render('index', {jsonData: Restaurants});
})
router.get('/restaurants_cluster', function(req,res, next){
res.render('index3', {datastr: JSON.stringify(Restaurants)});
// res.render('index', {jsonData: Restaurants});
})
module.exports = router;