title: Using Node.js as a simple web server
body: <p>I want to run a very simple HTTP server. Every GET request to <code>example.com</code> should get <code>index.html</code> served to it but as a regular HTML page (i.e., same experience as when you read normal web pages).</p>
  
  <p>Using the code below, I can read the content of <code>index.html</code>. How do I serve <code>index.html</code> as a regular web page?</p>
  
  <pre><code>var http = require('http');
  var fs = require('fs');
  var index = fs.readFileSync('index.html');
  
  http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end(index);
  }).listen(9615);
  </code></pre>
  
  <hr>
  
  <p>One suggestion below is complicated and requires me to write a <code>get</code> line for each resource (CSS, JavaScript, images) file I want to use. </p>
  
  <p>How can I serve a single HTML page with some images, CSS and JavaScript?</p>