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.

Revisions

  1. drblue created this gist Apr 6, 2020.
    16 changes: 16 additions & 0 deletions http.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    /**
    * 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");