Skip to content

Commit

Permalink
Fix: Added support for show_api in mount_gradio_app (#10097)
Browse files Browse the repository at this point in the history
* Fix: Added support for show_api in mount_gradio_app

* add changeset

* 2nd Fix: show_api in mount_gradio_app

* 3rd Fix: show_api in mount_gradio_app

* Update gradio/routes.py

* Update gradio/routes.py

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 8, 2024
1 parent d5b299c commit 43d88c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/two-ghosts-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Fix: Added support for show_api in mount_gradio_app
4 changes: 4 additions & 0 deletions gradio/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,7 @@ def mount_gradio_app(
path: str,
server_name: str = "0.0.0.0",
server_port: int = 7860,
show_api: bool | None = None,
app_kwargs: dict[str, Any] | None = None,
*,
auth: Callable | tuple[str, str] | list[tuple[str, str]] | None = None,
Expand Down Expand Up @@ -1557,6 +1558,7 @@ def mount_gradio_app(
favicon_path: If a path to a file (.png, .gif, or .ico) is provided, it will be used as the favicon for this gradio app's page.
show_error: If True, any errors in the gradio app will be displayed in an alert modal and printed in the browser console log. Otherwise, errors will only be visible in the terminal session running the Gradio app.
max_file_size: The maximum file size in bytes that can be uploaded. Can be a string of the form "<value><unit>", where value is any positive integer and unit is one of "b", "kb", "mb", "gb", "tb". If None, no limit is set.
show_api: If False, hides the "Use via API" button on the Gradio interface.
ssr_mode: If True, the Gradio app will be rendered using server-side rendering mode, which is typically more performant and provides better SEO, but this requires Node 20+ to be installed on the system. If False, the app will be rendered using client-side rendering mode. If None, will use GRADIO_SSR_MODE environment variable or default to False.
node_server_name: The name of the Node server to use for SSR. If None, will use GRADIO_NODE_SERVER_NAME environment variable or search for a node binary in the system.
node_port: The port on which the Node server should run. If None, will use GRADIO_NODE_SERVER_PORT environment variable or find a free port.
Expand All @@ -1578,6 +1580,8 @@ def read_main():
)

blocks.dev_mode = False
if show_api is not None:
blocks.show_api = show_api
blocks.max_file_size = utils._parse_file_size(max_file_size)
blocks.config = blocks.get_config_file()
blocks.validate_queue_settings()
Expand Down

0 comments on commit 43d88c3

Please sign in to comment.