How to reimplement the long-living shared auto-index client? #5201
Replies: 2 comments 3 replies
-
Hello @weinibuliu. I knew this would come up one day so I memorized things a bit in the codebase. In NiceGUI 2.x basically the approach boiled down to:
@app.get('/')
def _get_index(request: Request) -> Response:
return Client.auto_index_client.build_response(request)
Client.auto_index_client = Client(page('/'), request=None).__enter__() # pylint: disable=unnecessary-dunder-call
![]() If you really want to share a client (which, again, may or may not work), you only need to do task 1 of the above. See if it works, and get ready to fixing things if it doesn't. Cheers! |
Beta Was this translation helpful? Give feedback.
-
We now provide the "script mode" which should work as a drop-in replacement for the shared client in most of the circumstances. I wonder what the problem is in your code base. Can you, please, create a minimum reproducible example? This would allow us and the community to help more efficiently. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone!
First of all, I'm very excited that NiceGui has finally released version 3.0. I'm delighted to see the many improvements it includes. Therefore, I'm planning to migrate my project from 2.x to 3.x, but I'm running into some difficulties.
My project has almost all elements in the global scope because I'm using NiceGui as a web UI—it only serves a single user, not multiple users. This has the advantage of keeping the frontend and backend completely separate. Furthermore, when I access the page from another device on the local network, NiceGui doesn't need to rebuild a new page, and the content remains consistent across different pages.
I noticed that 3.0 removed the long-living shared client for various reasons, but I suspect it's something I'm relying on (and after initial attempts, it seems to be). Is there any way I can reimplement it myself?
Beta Was this translation helpful? Give feedback.
All reactions