-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
44 lines (30 loc) · 1.03 KB
/
server.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const express = require('express')
const fs = require('fs');
const port = 8000;
var app = express()
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html')
})
app.get('/:name(bnsf|cn|cp|csx|kcs|up|other)?', function (req, res) {
let rrname = req.params.name;
var raw_geojson;
switch(rrname) {
case "bnsf":
raw_geojson = fs.readFileSync('BNSF.geojson'); break;
case "cn":
raw_geojson = fs.readFileSync('CanadianNational.geojson'); break;
case "cp":
raw_geojson = fs.readFileSync('CanadianPacific.geojson'); break;
case "csx":
raw_geojson = fs.readFileSync('CSX.geojson'); break;
case "kcs":
raw_geojson = fs.readFileSync('KansasCitySouthern.geojson'); break;
case "up":
raw_geojson = fs.readFileSync('UnionPacific.geojson'); break;
case "other":
raw_geojson = fs.readFileSync('ShortLines.geojson'); break;
}
let parsed_geojson = JSON.parse(raw_geojson)
res.send(parsed_geojson)
})
app.listen(port, () => console.log(`Example app listening on port ${port}!`))