-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (31 loc) · 892 Bytes
/
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
var express = require('express');
var app = express();
var path = require("path");
var request = require('request');
var parser = require('xml2json');
//app.use(express.static(__dirname + 'public'));
app.use(express.static('public'));
app.get('/', function(req, res){
res.sendFile(path.join(__dirname, './index.html'));
});
app.get('/sensor', function(req, res){
request({
url: 'http://52.27.146.185:1026/v1/contextEntities/type/ThinkingThing/id/default',
headers: {
'fiware-service': 'smartGondor',
'fiware-servicepath': '/gardens',
'Accept': 'application/json'
}
}, function(error,response, xml) {
if (!error && response.statusCode == 200) {
res.json(xml);
//console.log(xml)
//res.json(parser.toJson(xml));
}
}
);
});
//response.sendFile(path.join(__dirname+'/index.html'));
app.listen(3000, function(){
console.log("running server");
});