title: Node.js: How to add to my app's index.html file from app.js file
body: <p>I'm experimenting with the sample Node.js app provided by AWS Elastic Beanstalk, and I want to dynamically insert content into the index.html file from the app.js file.</p>
  
  <p>I am just trying to get familiar with the platform and run some very basic tests.  I have looked extensively for answers, the closet thing I've found is here: <a href="https://stackoverflow.com/questions/34643522/how-to-change-front-end-html-using-node-js">How to change front-end html using node.js</a> but I do not understand the answer and I'm not sure it's relevant to me.  I am just working off the literal sample code provided by AWS so I was hoping this would be simple but it has been throwing me for a loop.</p>
  
  <pre><code>var html = fs.readFileSync('index.html');
  </code></pre>
  
  <p>is defined at the beginning of the file, and at the end of the function
  <code>http.createServer(function (req, res)</code> is the following lines:</p>
  
  <pre><code>res.writeHead(200);
  res.write(html);
  res.end();
  </code></pre>
  
  <p>From my understanding, this is how the index gets loaded and rendered to the user, upon a GET request.  I have tried replaced the 2nd line with <code>res.write("Hello");</code> and <code>res.write("&lt;p&gt;Hello&lt;/p&gt;");</code>, thinking that my entire page would get replaced with a simple Hello but there was no change whatsoever.</p>
  
  <p>I would just like to know how to edit the index.html file from this app.js file.  Anything to be able to make a change would be very helpful.  Please advise.  Let me know if more info is needed. Thank you in advance.</p>