title: node server (without Express) does not render image and it keeps loading at localhost
body: <p><a href="https://i.stack.imgur.com/DMJ9c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DMJ9c.png" alt="enter image description here"></a>I created a server without express and I'm trying to server a simple static webpage on localhost
  here is my code :</p>
  
  <pre><code>const fs = require('fs')
  const url = require('url');
  const hostname = 'localhost'
  const port = 3000;
  const path = require ('path');
  const http = require ('http')
  
  const server = http.createServer((req, res) =&gt; {
      if (req.url.match (/.css$/)) {
          let cssPath = path.join (__dirname, req.url)
  
          let cssReadStream = fs.createReadStream (cssPath, 'UTF-8')
          res.statusCode = 200;
          res.setHeader ("Content-Type", "text/css");
          cssReadStream.pipe (res)
      }
      if (req.url === "/") {
          fs.readFile("./index.html", 'UTF-8', (err, data) =&gt; {
              res.statusCode = 200;
              res.setHeader("Content-Type", "text/html");
              res.end(data);
  
          })
      }
      if (req.url.match (/.jpg$/)) {
          let jpgPath = path.join (req.url)
          console.log (jpgPath)
          let jpgReadStream = fs.createReadStream (jpgPath, 'UTF-8')
          res.statusCode = 200;
          res.setHeader ('Content-Type', 'image/jpg')
          jpgReadStream.pipe (res)
      }
  })
  
  server.listen (port, hostname, () =&gt; {
      console.log ('server start')
  }) 
  </code></pre>
  
  <p>first of all, it can display the HTML and CSS, however, localhost just keeps on loading after HTML and CSS displayed. Second of All, the image cannot be display (a instagram icon name icon.jpg).
  the end result should look something like this:</p>
  
  <p>I guess it has something to do with the favicon thing, but how do i fix it?</p>
  
  <p><a href="https://i.stack.imgur.com/V2FrK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V2FrK.png" alt="enter image description here"></a></p>