Created
          April 6, 2020 15:28 
        
      - 
      
 - 
        
Save drblue/d753c9e2ad2579c04255e566be0a0618 to your computer and use it in GitHub Desktop.  
    node.js http server example
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * 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