Skip to content

Instantly share code, notes, and snippets.

@evgenius
Last active November 6, 2018 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evgenius/f8337dabd776b5a373f1633a80fa89a6 to your computer and use it in GitHub Desktop.
Save evgenius/f8337dabd776b5a373f1633a80fa89a6 to your computer and use it in GitHub Desktop.
const http = require('http');
const requestHandler = (req, res) => {
const { remoteAddress, remotePort } = req.socket;
console.log(`Got a request from ${remoteAddress}:${remotePort}`);
res.end('Hello');
};
const server = http.createServer(requestHandler);
const port = 8000;
server.listen(port, () => {
console.log(`Listening on the port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment