title: Serving HTML file from Node server
body: <p>Pretty much purely for pedagogical purposes, I'm serving both my front and back end data out of my one node server. Right now, I'm at the point where I've received my client request successfully, created some data based on said request, am able to console log it, etc. Everything is fine up to that point. My issue is that in the event that my data is only an html file, which is being read with the fs library, it will not render on the page when I attempt to serve it out in my res.end() or res.write(). I can see it's exactly what I want and expect when I console log it, but it just doesn't render in the browser. Any help would be appreciated. I've got it set up to where I'm handling my requests in an "if/else" wherein I only have the two scenarios of "/" (home), in which case I serve the html file, and anything else because the server really only needs to handle those two events. Thanks in advance.</p>
  
  <p>Edit. This is what I have so far:</p>
  
  <pre><code>function responseHandler(req, res) {
   res.writeHead(200, {"Content-Type": "text/html"});
   if (req.url.match("fav")) {
     res.end("");
     return;
   }
   else if (req.url.match("/endpoint")) {
     var input = req.url.match(/endpoint\/(.*)/)[1];
     var output = endpoint.toHTML(decodeURI(input));
     res.end(data);
     console.log(input, req.url)
   }
   else {
     fs.readFile("index.html", "utf8", function(err, data) {
       console.log("data:" + data);
       var input = req.url.match(/endpoint\/(.*)/)[1];
       var output = endpoint.toHTML(decodeURI(input));
     });
   }
  
   res.end();
  }
  </code></pre>
  
  <p>I can see the data in the console which, in the last case, is just my HTML file. It just won't render in the page.</p>