Skip to content

Instantly share code, notes, and snippets.

@ktwrd
Last active February 23, 2021 04:15
Show Gist options
  • Save ktwrd/25974d59e2ad11dbb786ed0bbdff16ec to your computer and use it in GitHub Desktop.
Save ktwrd/25974d59e2ad11dbb786ed0bbdff16ec to your computer and use it in GitHub Desktop.
Temporary HTTP Server
/*
This is only meant for use where you are testing if a server can recieve HTTP requests.
*/
const http = require("http");
const toolbox = require("tinytoolbox")
const port = parseInt(toolbox.stringGen(5,7));
http.createServer(function (req, res) {
// console.log(req);
console.log(req.headers);
console.log(req.connection.remoteAddress);
res.write("Pong!");
res.end();
}).listen(port);
console.log(`[Debug] Started HTTP server on port '${port}'`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment