2

Anyone has an idea how to execute a nodejs file on button click of HTML?

Comments
  • 5
    Use click to save to a database, write a simple script to check that table periodically, easy peasy😂
  • 1
    @ozzy actually I have a script which opens notepad program. I am developing this project using nwjs, on the click of a button I want this script to be executed, I tried including the script in HTML file and call the function which has my script's code but it's not getting executed...

    PS: I am not using any database.
  • 4
    On click event sends websocket feedback to the server, on getting that feedback the server (node js socket listener.. think socket.io or something) just open/execute the file?
  • 0
    @incognito yep that will do
  • 2
    That sounds....
    Are you sure you want to execute random node js scripts in the server? as input by the users? Absolutly sure?

    then implemnt a simple rest api that accepts the file sent, and sends it to a dedicated executor that later publishes the result to the ui via websocket.
  • 1
    I think they're wanting to execute a predefined script, not a user entered one. Of course... then it just sounds like any other button that calls back to the server...
  • 0
    @BluePanda any reference links?
  • 0
    @M1sf3t I want to open a TXT file in notepad on button click, I was able to open the TXT file in note using npm package but this works only when I run it in CMD, it doesn't works when I call the function on button click(event listener) from web... I figured that it needs to be executed as web doesn't execute the js file...

    So I need a solution to this which will execute the file on button click
  • 0
Add Comment