0

try.html file:-

<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <input type="button" class="btn" id="processbtn" value="Process" onclick="get_tt()" />
    <script src="try3.js"></script>
  </body>
</html>

try3.js file:-

function get_tt() {
    document.getElementById("processbtn").value = "Hang on..."
    var python = require("python-shell")
    var path = require("path")

    var options = {
        scriptPath: path.join(__dirname, ''),
        pythonPath: 'C:/Users/Lenovo/Anaconda3/python'
    }

    var f = new python("hello.py", options);
    f.end(function(err, code, message) {
        document.getElementById("processbtn").value = "Done";
    })
}

The python code is not executing using this code. The value of button changes to Hang on... ,and remains in the same state.

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
K.U.
  • 17
  • 3
  • Hi KU. What is the content of the `hello.py` file? Since you have a listener for the `end` event it could be that your script is not terminating properly and you never get the end event. Also, you can log to a file or something od the sort from the python file to make sure it's being called. Do you see any errors on the console? – limoragni Mar 01 '19 at 10:09
  • @limoragni hello.py :- import sys print('Hello from Python!') sys.stdout.flush() – K.U. Mar 04 '19 at 05:22

0 Answers0