|
|
@@ -8,6 +8,7 @@ const app = express();
|
|
|
|
|
|
const _datasetsFilePath = 'data/datasets.csv';
|
|
|
const _dataFilePath = 'data/data.csv';
|
|
|
+const _clustersFilePath = 'data/clustering/out_file.csv';
|
|
|
var _datasets = undefined;
|
|
|
var _ruralData = undefined;
|
|
|
|
|
|
@@ -144,6 +145,27 @@ app.get('/runR', (req, res, next) => {
|
|
|
);
|
|
|
});
|
|
|
|
|
|
+app.get('/clusters', (req, res, next) => {
|
|
|
+ //console.log(console);
|
|
|
+ console.log('calling R...')
|
|
|
+ R('./r/selected_data.r').call(
|
|
|
+ function(err, data) {
|
|
|
+ console.log('R done');
|
|
|
+ if (err) {
|
|
|
+ console.log(err.toString('utf8'));
|
|
|
+ data = { result: err.toString('utf8') };
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.log(data);
|
|
|
+ nutsData.loadClusters(_clustersFilePath, function(clusterData) {
|
|
|
+ data = clusterData;
|
|
|
+ helpers.formatResponse({ response: data }, req, res);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+});
|
|
|
+
|
|
|
// start the service on the port xxxx
|
|
|
app.listen(3000, () => console.log('Rural attractivity WS listening on port 3000...'));
|
|
|
|