title: Setting a document root to your Node.js http server?
body: <p>I just setup a basic node.js server with socket.io on my local machine. Is there a way to set a document root so that you can include other files. Ie. Below I have a DIV with a a background image. The path the image is relative to the location of the server, however this is not working. Any ideas? Thanks!</p>
  
  <pre><code>var http = require('http'),  
      io = require('socket.io'), // for npm, otherwise use require('./path/to/socket.io') 
  
  server = http.createServer(function(req, res){ 
   // your normal server code 
   res.writeHead(200, {'Content-Type': 'text/html'}); 
   res.end('&lt;div style="background-image:url(img/carbon_fibre.gif);"&gt;&lt;h1&gt;Hello world&lt;/h1&gt;&lt;/div&gt;'); 
  });
  server.listen(8080);
  
  // socket.io 
  var socket = io.listen(server); 
  </code></pre>