title: Displaying local images in static html served by NodeJS
body: <p>I have a NodeJS app that renders index.html, but I can't get index.html to find the images in the folder it's located in.</p>
  
  <p>Here are the contents of index.js</p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  
  app.get ('/', function(req, res){
      res.sendFile(__dirname + '/index.html');
  });
  http.listen(80, function(){
      console.log('listening on *:80');
  });
  </code></pre>
  
  <p>It serves index.html successfully but all images I supply it are broken links.
  The following html does not work</p>
  
  <pre><code>&lt;img src="img/myimage.png"&gt;
  </code></pre>
  
  <p>and my file structure is</p>
  
  <pre><code>myApp - folder
      index.js
      index.html
      img - folder
          myimage.png
  </code></pre>
  
  <p>I've tried several variations such as</p>
  
  <pre><code>&lt;img src="/img/myimage.png"&gt;
  &lt;img src="./img/myimage.png"&gt;
  </code></pre>
  
  <p>I've also tried placing the image directly in the app folder with index.html and trying</p>
  
  <pre><code>&lt;img src="myimage.png"&gt;
  </code></pre>
  
  <p>But the link to the image is still broken.</p>