Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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 3
lbendlin
Super User
Super User

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

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

pratimak_0-1698853446258.png

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.