Created
December 19, 2018 22:30
-
-
Save MarcoPolo/0d3186becbce74bc8f21c9deab33dcc0 to your computer and use it in GitHub Desktop.
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
var http = require('http') | |
var fs = require('fs') | |
var server = http.createServer(function(request, response) { | |
var req = request | |
response.writeHead(200, {'Content-Type': 'textplain'}) | |
if (req.method === 'POST') { | |
var body = '' | |
req.on('data', function(data) { | |
body += data | |
}) | |
req.on('end', function() { | |
console.log('Body: ' + body) | |
fs.writeFile(`/tmp/android-timings/${new Date().toISOString()}.json`, body, function(err, data) { | |
if (err) { | |
console.log('err writing', err) | |
} | |
}) | |
}) | |
response.writeHead(200, {'Content-Type': 'text/html'}) | |
response.end('post received') | |
} | |
response.end('Undefined request .') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment