Created
August 21, 2013 18:39
-
-
Save jonasfj/6298450 to your computer and use it in GitHub Desktop.
Test server for printing telemetry data to terminal...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/node | |
var express = require('express'); | |
var zlib = require('zlib'); | |
var fs = require('fs'); | |
var app = express(); | |
app.post('/*', function(req, res){ | |
console.log("-----------------------------------------------------------------------------"); | |
console.log('POST /' + req.originalUrl); | |
var chunks = []; | |
req.on('data', function(chunk){ | |
chunks.push(chunk); | |
}); | |
req.on('end', function(){ | |
zlib.gunzip(Buffer.concat(chunks), function(error, result){ | |
var data = JSON.stringify(JSON.parse(result.toString()), null, 2); | |
console.log(data); | |
fs.writeFile("telemetry-ping.log", data); | |
}); | |
}); | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('thanks'); | |
}); | |
port = 3000; | |
app.listen(port); | |
console.log('Listening at http://localhost:' + port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment