I have a nodejs scpirt that do some work and save result to the text file. Also i have index.pug with basic template that compiles to html. How can I display the result of a script using a pag on an html page?
Asked
Active
Viewed 66 times
0
-
Does this answer your question? [Read a file in Node.js](https://stackoverflow.com/questions/18386361/read-a-file-in-node-js) – Lawrence Cherone Jun 03 '21 at 12:59
-
How can I load my script or its result, a text file into an html file to display on the page? – kumite Jun 03 '21 at 13:07
-
have linked to how you do that, then pass the parsed value (you're not showing format, so is unanswerable) to `res.render` (basic stuff, rtm http://expressjs.com/en/guide/using-template-engines.html) – Lawrence Cherone Jun 03 '21 at 13:09
-
Can you elaborate how do you want to use nodejs script? – Abhishek Pankar Jun 03 '21 at 13:54
-
Yes, in the script there is a function that makes a listing of a directory in Linux, and writes the result to a file. I would like to display the contents of this text file in the browser along with the css and the rest. – kumite Jun 03 '21 at 15:05
1 Answers
0
Read the contents of the file in the route handler, transform the results and store it in the variable which you pass to the context of the template. Within the template transform the results whatever the way you wish.

Biller Builder
- 303
- 3
- 10