title: Node js. sending an html that contains an image
body: <p>I have built a simple server using node js.
  I wish to send an html that contains an image inside.</p>
  
  <p>Ok, so i know how to send back an html file.
  And i know how to send back an image.</p>
  
  <p>When i send the html response with the <code>&lt;img src = 'green2.jpg'&gt;</code> in it, 
  the page loads with a broken image.</p>
  
  <p>Any ideas?</p>
  
  <p>Relevant code :</p>
  
  <pre><code>var net = require ('net');
  var url = require('url');
  var fs = require('fs');
  
  var server = net.createServer(function (socket) {
      socket.on('end', function() {
          console.log('server disconnected');
      });
  
      socket.on('data', function(data) {
          get();
      });
  
      var get = function (parse) {
          fs.readFile('example.html',  function(err, data) {
              if (err) throw err;
              socket.write('HTTP/1.0 200 OK\r\nDate: Fri, 31 Dec 1999 23:59:59 GMT\r\nContent-Type: text/html\r\n\r\n');
              socket.write(data);
              socket.end();
          });
      }
  });
  
  server.listen("8888");
  </code></pre>