Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago

How to run python script on the remote server by clicking a button on the Power BI report.

Hello,
Need help to run python script which is on remote server or local machine using button in power bi report! 
Thanks in Advanced!  

3 Replies

  • Please provide a more detailed explanation of what you are aiming to achieve. What have you tried and where are you stuck?

    • Anonymous's avatar
      Anonymous
      Not applicable

      lbendlin - I have very simple web application (using flask) which I started local machine, it has API Call - In my example it is 'test_script' and that API is calling through power bi button - as action on button I selected web link passed value as "http://127.0.0.1:5000/test_script" . It working but it open to html page. My requirement is I just want to trigger that python execution not to open any html page. 

      Below is python script. 

      from flask import Flask, render_template
      import datetime
      
      app = Flask(__name__)
      
      @app.route("/")
      def hello_world():
          return render_template('home.html')
      
      @app.route("/test_script")
      def test_script():
          file = open(r'D:\workspace\Log Files\test.txt','a')
          file.write(f'{datetime.datetime.now} - The Script Ran \n')
          data = "Running Python Script"
          return render_template('home.html', data=data)
      if __name__ == '__main__':
          app.run(debug=True)

      here is web url I keep on power bi button

       

      • lbendlin's avatar
        lbendlin
        Super User

        That will always open a browser session.  Consider using a Power Automate visual instead, with a flow that runs the HTTP request.