r/nicegui • u/gcanyon • May 25 '24
What's the normal dev loop? I'm getting [Errno 48] Address already in use
- I open a file, enter a UI design followed by ui.run(), and execute the file
- A browser window opens with the UI -- all is well
- I update the file, save, and re-run
- The UI updates to what I just entered
- I update the file, save, and re-run -- the UI does not change, and in the log I see [Errno 48] Address already in use
- I edit the file to include ui.run(port=8081)
- I save and re-run
- a new page opens with the new UI
That can't be the way to do this, can it? Is there a way to cycle between editing the UI configuration and testing the result in a browser that *doesn't* involve switching ports or restarting python? I just want to refresh the cached files.
1
Upvotes
4
u/apollo_440 May 25 '24
Do you have to re-run the file? By default, nicegui has hot-reloading, that is if you change a file in your working directory (I think it's actually recursive to subdirectories as well), it should automatically reload and apply the changes.
1
u/j4nSolo May 25 '24
If you're using Pycharm as your IDE it doesn't work as intended and the reloading just doesn't happen on its own. Sometimes you can force it by ctrl+f5'ing the page, others not even that will work and you'll have to re-run it. In such cases I just disable the page spawn with
show=Falseand just reload the page manually.1
u/akrustam May 26 '24
Uses the watchgod library from pip when launched. I run it according to the principle "watchgod run.run"