I have a python script that uses PySimpleGuiWeb. I want to host it on my server and connect to it from another computer. But the script is running on 127.0.0.1. Can I somehow change this, or is there another way?
-
1Not too sure if PySimpleGuiWeb is outwardly accessible. It might be worth looking into Flask if you want to host a Python web interface. – Kane Apr 19 '22 at 04:45
-
PySimpleGUIWeb run in your own localhost. Upload the code to the web server and run it from there or use [this](https://stackoverflow.com/a/15431636/18298515). – BrainFl Apr 20 '22 at 03:00
-
Also, you have to keep your code run, or else it's not accessable. – BrainFl Apr 20 '22 at 03:01
1 Answers
From the host device running the pysimplegui python script, you can likely load the gui via 127.0.0.1:###### through a browser (where ##### is your port). This is because it's hosted and being accessed from the same device.
Accessing from another device on the same network: try using the IP of the device hosting the pysimplegui followed by the same port as is used locally by host device to access gui.
e.g. 172.20.10.5:######
IP of the host device found via: Linux(terminal): ifconfig Mac(terminal): ifconfig Windows(command prompt): ipconfig
You can make the IP of your gui host device static and according the pysimplegui you can make the port static too, therefore the GUI should be always found at the same IP:port externally (given the static IP holds and doesn't get reallocated and that port isn't blocked for any reason by network etc.)
Update: In addition, with some further reading, optional arguments to a 'Window' include: web_ip='0.0.0.0', web_port=0 https://github.com/PySimpleGUI/PySimpleGUI/blob/master/PySimpleGUIWeb/PySimpleGUIWeb.py
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 23 '22 at 10:43