To refresh/execute a Python script (calling API endpoints) as a Data Source in Power BI, Microsoft only allows an OnPrem Gateway (Personal Mode), thus requiring the developer of the dashboard to keep their laptop on.
Provided we have a Windows server always running, on which we’ll install the Gateway, I see two options for allowing (other) users to be able to refresh a Power BI mobile app, accessing live data on their phones, also outside of the LAN:
- Code the Power BI dashboard on this server, so the workbook/Python code and dependencies live there, and not on a personal laptop, and use OnPrem Personal Mode.
- Code the dashboard on a personal laptop, without Python as a Source but using Web as a Source, and set up a custom web server (think: Flask) on the Windows server, whereby the Flask app runs the script and returns the results in a html <table> format that Power BI triggers by accessing, say, 192.168.X.X:5000, and can easily digest. This would also allow me to use a Raspberry Pi/Linux server for everything but the Gateway which would run on a headless Windows VM.
Is this understanding generally correct, and which is the better option?
I have tried option 2, by deploying both a SOCAT listener and a basic Flask app, to execute the Python script and it indeed returns the results in a 1-column, multi-row table format which Power BI easily interprets. It, however, seems like a hack solution. I am looking for the best practice to use in a corporate environment.