-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.js
38 lines (30 loc) · 949 Bytes
/
gui.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
var http = require('http'),
csv = require('csv'),
express = require('express');
var app = express();
app.use(express.static(__dirname));
app.get('/destinations', function(req, res){
dumpToCSV(req.param('destinations'),"destinations.csv");
res.send('Done');
});
app.get('/connectivity', function(req, res){
dumpToCSV(req.param('connectivity'),"beacon_connectivity.csv");
res.send('Done');
});
app.get('/import_nodes', function(req, res){
var balls = [];
csv()
.from.path('./calibration.csv', { comment: '#', delimiter: ',', escape: '"' })
.to.array(function(data){
data.forEach(function(row){
balls.push([row[1],row[2],row[3],row[4]]);
});
console.log(balls);
res.send(balls);
});
});
app.listen(1337);
console.log('Listening on port 1337');
var dumpToCSV = function(data, filename) {
csv().from(data).to(filename);
};