Skip to content

Instantly share code, notes, and snippets.

@m0ppers
Last active August 29, 2015 14:22
Show Gist options
  • Save m0ppers/3709f7d87b73be9aca7b to your computer and use it in GitHub Desktop.
Save m0ppers/3709f7d87b73be9aca7b to your computer and use it in GitHub Desktop.
var http = require("http");
var net = require("net");
var httpAddress = "0.0.0.0";
var httpPort = "8001";
server = http.createServer(function (req, res) {
console.log("GOT REQUEST");
var postBody = JSON.stringify({});
var options = {
hostname: '192.168.1.11',
port: 80,
path: '/upload',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': postBody.length
}
};
var backendRequest = http.request(options, function(res) {
console.log("GOT RESPONSE");
});
backendRequest.on("error", function(e) {
console.log("ERR", e);
res.end("watt");
});
backendRequest.write(postBody);
});
server.listen(httpPort, httpAddress);
console.log("Server running at http://<ip-address>:" + httpPort + "/");
// bash: curl --max-time 5 http://localhost:8001; curl --max-time 5 http://localhost:8001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment