-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathn4.js
More file actions
33 lines (29 loc) · 938 Bytes
/
Copy pathn4.js
File metadata and controls
33 lines (29 loc) · 938 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
var express = require("express");
var myParser = require("body-parser");
var app = express();
var port = 7070;
var data;
var o = process.stdout;
app.use(myParser.json());
app.use(myParser.urlencoded({extended : true}));
app.post("*", function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
o.write('--------------------------');
o.write('\n method = ' + req.method);
o.write('\n -> ' + req.url);
o.write('\n ');
var len = req.body.length;
req.body.forEach(function (item){
o.write('\n Payload: ' + JSON.stringify(item.data));
o.write('\n Full string: ' + JSON.stringify(item));
o.write('\n id: ' + JSON.stringify(item.id) + '[');
o.write('\n');
item.data.forEach(function (datum) {
o.write(' ' + datum.timestamp);
o.write(' --> ' + datum.value);
});
o.write('\n ]');
});
});
app.listen(port);
console.log('Server running at http://localhost:' + port + '/');