Node JS

Auto Refresh the web page using Node JS and PUG

Recently I was working on the Web Framework project using PowerShell and Python which eventually made me to learn more. My requirement was to refresh the web page which helps a small monitoring team. In this blog post I will share the base logic and yes it requires improvement and in my next blog I will share the complete solution.

Requirement: Auto refresh the page at certain interval!

For a demo I used Get-Date cmdlet (Ticks and Second property)

Output is as expected!

Take a look at the server.js file!

Let me brief the above demo route = We are calling the PowerShell file using the child_process inbuilt module and and rendering the data in the web page. Here, result is the JSON parsed values which is assigned to dateTime object.

Now, see how it is used in the PUG file.

Cool Right? Here comes the auto refresh logic!

We call this autoRefresh.js using the script include in PUG!

Enjoy Node and PUG! In this blog

Leave a Reply

Your email address will not be published. Required fields are marked *