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.
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: How to change front-end html using node.js 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.
var html = fs.readFileSync('index.html');
is defined at the beginning of the file, and at the end of the function
http.createServer(function (req, res) is the following lines:
res.writeHead(200);
res.write(html);
res.end();
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 res.write("Hello"); and res.write("<p>Hello</p>");, thinking that my entire page would get replaced with a simple Hello but there was no change whatsoever.
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.