如何通过按钮单击网页在远程服务器上运行python脚本?

I have a python program on remote server. I need to create a web page (html code present in same directory as that of python script on server) having a button on clicking which python script should run. One more thing is that we need to choose a file from local machine after which the python script takes that file as input, runs and outputs another file which needs to be displayed on web page.

I don't know what to use javascript or ajax or php to achieve this. I tried out different ways but in vain.

This is the html code I have been trying with...

<!DOCTYPE html>
  <html>
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

      <script>
       $(document).ready(function(){
        $("button").click(function(){

         // var file = $('#fileInput')[0].files[0]
         var fd = new FormData();
         fd.append('fileInput', file);
         // console.log(fd)
         $.ajax(
          {
                type: "POST",
                url: "./summarize.py",
                data: "fd"
                success: function (response) {
                  
                }
              // error: function (response) {}
          });
       });
      });

      </script>
   </head>
    
   <body>
      <h3>Upload reviews file</h3>
      <input type="file" id="fileInput" name="fileInput">
      <p>Click the "Get summary" button to summarize the reviews.</p>
      <button>Get summary</button>
   </body> 

</html>

I have searched online but no where the answer was specific (I felt so). Since I am new to javascript, I have trouble in following them. Someone kindly explain what is to be done.

Thank you.

</div>

I think you can use php exec, to run Python and your summarize.py script.

<?php
// @result array
exec("python summarize.py", $result);

PHP exec will return you result. Also you can use django or other frameworks to run your Python code.