Skip to content

Instantly share code, notes, and snippets.

@drblue
Created April 6, 2020 15:28
Show Gist options
  • Save drblue/d753c9e2ad2579c04255e566be0a0618 to your computer and use it in GitHub Desktop.
Save drblue/d753c9e2ad2579c04255e566be0a0618 to your computer and use it in GitHub Desktop.
node.js http server example
/**
* http
*/
const http = require('http');
const server = http.createServer();
server.on('request', function (req, res) {
// code here
res.writeHead(200, {
'Content-Type': 'text/html',
});
res.end(`Hello, browser! It's ${Date()} right now.`);
});
server.listen(8080);
console.log("Server listening on http://127.0.0.1:8080");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment