Execute Python script from HTML button in Angular Js UI

22 views
Skip to first unread message

Yash Kashyap

unread,
May 8, 2020, 1:53:03 PM5/8/20
to Angular and AngularJS discussion

Hi Everyone,

I want to execute a python script which contains some shell commands, by clicking an HTML button in Angular Js UI. So far I've done this,
```
 <input type="button" id='script' name="scriptbutton" value=" Run Script " onclick="goPython()">

 <script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
    <script>
        function goPython(){
            $.ajax({
              type: 'GET',    
              url: 'script.py',
      success: function(data){
       alert(data);
      console.log('success',data);
 });
   </script>
```
However, i nthe console I only get the contents of the script, the script itself doesn't  get executed. I googled and found that I need to make an $http to my python script and set up a listener in that script as well. But I don't know how to achieve that. Can you guys help me what I need to do to execute the python script by clicking the button.

Thanks
Reply all
Reply to author
Forward
0 new messages