Skip to content

Instantly share code, notes, and snippets.

@LautaroJayat
Last active January 26, 2020 17:05
Show Gist options
  • Select an option

  • Save LautaroJayat/aa79cf91c2708927313d24f88d1a33a2 to your computer and use it in GitHub Desktop.

Select an option

Save LautaroJayat/aa79cf91c2708927313d24f88d1a33a2 to your computer and use it in GitHub Desktop.
index.js - step 3 Sending data.
const server = http.createServer((req, res) => {
// Let store our URL and Method in a variable
const URL = req.url;
// Lets make something using conditionals
if (req.url === '/') {
// Note that we are using res.write() method and then using res.end().
// This is mandatory if you expect your server to work fine.
res.write('Yea! Its Working! Esoteric Knowledge!', 'utf-8', () => {
console.log('console.log from the callback function!')
});
res.end();
}
}).listen(PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment