Skip to content
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

Fix: Added support for show_api in mount_gradio_app #10097

Merged
merged 12 commits into from
Dec 8, 2024
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
Loading