-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow building multipage Gradio apps #10433
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-pypi-previews.s3.amazonaws.com/1fb08530e719e073c9741898d6923c51d2b3f547/gradio-5.14.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@1fb08530e719e073c9741898d6923c51d2b3f547#subdirectory=client/python" Install Gradio JS Client from this PR npm install https://gradio-npm-previews.s3.amazonaws.com/1fb08530e719e073c9741898d6923c51d2b3f547/gradio-client-1.10.0.tgz Use Lite from this PR <script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/1fb08530e719e073c9741898d6923c51d2b3f547/dist/lite.js""></script> |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
I get this error when trying
|
Whoops fixed |
Thanks @aliabid94, the demo is working for me now in regular mode.
![]() Btw without SSR, multipage does feel a bit slow on Spaces: https://huggingface.co/spaces/abidlabs/multipage
|
gradio/routes.py
Outdated
@@ -592,6 +609,7 @@ def api_info(request: fastapi.Request): | |||
@app.get("/config", dependencies=[Depends(login_check)]) | |||
def get_config(request: fastapi.Request): | |||
config = utils.safe_deepcopy(app.get_blocks().config) | |||
# del config["page"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to remove this comment?
I'm not sure I agree about moving the links to the right but I do like the background shading idea! I do think we need the nav links to stand out a bit more. I can also experiment a little bit myself. |
SSR mode (and dev mode) now work @abidlabs |
I agree! In terms of a visual heirarchy, if a gradio app has both pages and tabs, the page links in the navbar should be more prominent but right now, they are less prominent than the tabs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was testing out the latest commit. The multipage demo works well (event tried sub-mounting it into a larger fastapi app and it worked). But I noticed that a vanilla interface demo (demo/calculator
) will not render? Doesn't happen with Blocks or ChatInterface.
This is the error in the console
Uncaught (in promise) RangeError: Maximum call stack size exceeded
at get_slot_context (svelte.js:169:26)
at create_slot (svelte.js:164:20)
at fe (Block.svelte:91:24)
at _e (Block.svelte:60:11)
at init (svelte.js:3283:34)
at new ae (Block.svelte:40:10)
at ue (Index.svelte:80:16)
at init (svelte.js:3283:34)
at new Se (Index.svelte:55:17)
at Object.construct (RenderComponent.svelte:31:11)
2025-02-04_10-56-47.mp4
Fixed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! Noticed a couple of small issues. Also reload mode does not work with multiple pages (every link in the navbar will point to the same page).
I think I've fixed them all now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well in my tests locally and on Spaces. Great work @aliabid94!
Closes: #2654
Implemented multipage. This is the syntax:
See
demo/multipage/run.py
below:Initially I had implemented separate routes as separate Blocks but then it got real messy with trying to unify the queue, Stateholder and other backend things across multiple Blocks, so now we just keep the configs separate for different pages but the Blocks is shared.
Did not yet implement shared state or components across pages, because it's still unclear what the intended behaviour should be, still need to discuss.