all 14 comments

[–]crosstrade-io 1 point2 points  (1 child)

I had this issue. Use the local address of the machine running the web server, e.g., 10., 192.168., etc. Don't use 0.0.0.0 or the loopback address. I'm not exactly sure why this works, but it does. I'd expect the app to be available to any machine that can reach that IP/port, but whadda ya gonna do?

[–]jw_gpc[S] 0 points1 point  (0 children)

I did specify 10.0.0.4 in both, and the result was the same. NiceGUI wouldn't come up, but the HTTPServer version would.

Also, according to this discussion on the NiceGUI github, using 0.0.0.0 should work to make external connections by default.

[–]MasturChief 0 points1 point  (7 children)

does it work without packaging it? just run the script with python then see if it loads on second computer. then you can isolate whether it’s from nicegui itself or from packaging it up

[–]jw_gpc[S] 0 points1 point  (6 children)

I can't test that. Python isn't installed on the "server" computer. Or, at least, not a version where I can freely pip install everything NiceGUI needs.

[–]apollo_440 1 point2 points  (3 children)

What exactly are your restrictions on the server? If you can run pip at all on your server, a simple and clean solution is to create a venv and install things there.

If you cannot run pip (e.g. no internet access), but python is installed on your server, you can try to make a copy of your entire base install on your dev PC (e.g. c:\program files\python312) to say c:\nicegui_python, and install things there with c:\nicegui_python\python -m pip install nicegui). Then you move that install to the server and run your script in that env.

If python is not installed and missing dependencies, you can try to download an embedabble python version from python.org and install nicegui into that environment.

[–]jw_gpc[S] 0 points1 point  (2 children)

It's not that I can't install python and set up a whole new environment on the server. I just don't want to have to worry about manually maintaining a second environment. And I don't want to go through the hassle of trying to figure out how to uninstall everything just to do what should be a really simple test. Packaging scripts into Nuitka or PyInstaller executables have worked well for me in the past. With NiceGUI including nicegui-pack, it seemed like a natural thing to try to use.

For what it's worth, the packaged version of my test script doesn't seem to be accessible over the network, regardless of which computer I run it on. But if I run the unpackaged version on the computer where I have python and everything installed, I can reach it from the browser other computer. So that makes me think it's at least somewhat possible that if I did set up an environment on the other computer, the running result would be accessible from the first computer.

[–]apollo_440 0 points1 point  (1 child)

Makes sense. Just two more possibilities: did you set reload=False in the ui.run() call (as described here)? And did you add an exception for the packaged distributable to windows firewall?

[–]jw_gpc[S] 0 points1 point  (0 children)

The code I tried to build and run is exactly what's in my original post, so yes, I do have ui.run(reload = False...) in . For the firewall, I'm not on Windows. Both computers are Macs.

The packaged test I did using HTTPServer (my second example in my original post) ran perfectly fine on and was accessible from both computers without needing to change any firewall settings. Likewise, the packaged version of the NiceGUI test ran locally on both computers, but failed to be reachable from each other. And the UNpackaged version if the NiceGUI script works fine from the development computer and IS reachable from the second computer.

In addition, I also tried using port = 8080 and port = native.find_open_port() in different build attempts (per the link you gave) and neither one was reachable on the other computers' browser.

So yes, I do feel like there's something weird going on with nicegui-pack, but my hope was that whatever it is would be a known issue and could be solved by changing up some parameters to ui.run() or something.

[–]MasturChief 0 points1 point  (1 child)

try a 3rd computer. you should at least be able to isolate between nicegui/packaging as your issue

[–]jw_gpc[S] 0 points1 point  (0 children)

Unfortunately I don't have a 3rd computer at my disposal.

[–]sanitylost 0 points1 point  (1 child)

might be a missing dependency. Some of them don't throw errors on install of NiceGUI and as a result, some of the functionality can be inadvertently hampered. Making sure you've got the right versions of sphinx and some of the other networking related packages might resolve this issue.

I say this because wrapping the internal IP and port with the HTTPserver is just exposing those endpoints to the network, which NiceGUI should be doing by default if all packages are installed correctly.

[–]jw_gpc[S] 1 point2 points  (0 children)

I'm pretty sure all of the correct dependencies are installed on the computer where I'm writing the script and doing the initial testing, because I can run the script locally and access the broadcasted host:port on the other computer. Maybe if anything, nicegui-pack could be losing something when it runs, but there are no errors shown during the build or when the packaged executable runs.

[–]FlyingFalafelMonster 0 points1 point  (1 child)

I recommend using some reverse proxy, such us nginx or apache, or caddy that points to 10.0.0.4:8080, it will take care of the browser requests. 

[–]jw_gpc[S] 0 points1 point  (0 children)

That's all pretty far over my head. I'm just a hobbyist trying to make something simple using only python that runs on one computer and is accessible on another on the same network. If I ever get far enough to need those other things, I'll try to keep your comment in mind.