-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (34 loc) · 850 Bytes
/
app.js
File metadata and controls
41 lines (34 loc) · 850 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const express = require('express');
const updateData = require('./appModules/updateData');
const fs = require('fs');
const app = express();
updateData();
app.use(express.static('./public'));
app.get('/plotter', (req, res) => {
res.sendfile('./index.html');
});
app.get('/plotter/:id', (req, res) => {
let dataId = req.params.id;
if (dataId == 1) {
fs.readFile('./appData/matchPerSeason.json', 'utf8', (err, data) => {
res.json(data);
});
}
else if (dataId == 2) {
fs.readFile('./appData/wonPerSeason.json', 'utf8', (err, data) => {
res.json(data);
});
}
else if (dataId == 3) {
res.json([1, 2, 3]);
}
else if (dataId == 4) {
res.json([1, 2, 3]);
}
else if (dataId == 5) {
res.json([1, 2, 3]);
}
else res.sendStatus(404);
});
app.listen(3000);
console.log('listening at 3000');