title: Display contents of file on HTML page
body: <p>I am looking for a way to display the contents of a directory on an HTML page. I have the following snippet of code:</p>
  <pre><code>const fs = require(&quot;fs&quot;);
  let directory_name = &quot;/example&quot;;
  let filenames = fs.readdirSync(directory_name);
  console.log(&quot;\nFilenames in directory:&quot;);
  filenames.forEach((file) =&gt; {
     console.log(&quot;File:&quot;, file);
  });
  </code></pre>
  <p>This will display the contents of the file in the terminal(console) but I am looking for a way to change the &quot;console.log(&quot;File:&quot;, file)&quot; line into a statement to send the elements to my HTML page.</p>
  <p>Any help would be appreciated.</p>
  <p>Using Linux btw</p>