Repository: gradio-app/gradio
Pull request: Fix: Added support for show_api in mount_gradio_app
Fix: Added support for show_api in mount_gradio_app

## Description
The `mount_gradio_app` function did not previously support the `show_api` parameter, which caused the "Use via API" button to always appear, regardless of the user's intent.

### Changes
- Added logic to handle `show_api` in `mount_gradio_app`.
- Ensured `show_api` is correctly passed to the `Blocks` instance.


Closes: #9980 

  


Problem statement:
Cannot set show_api to False in mount_gradio_app
### Describe the bug

I create a gradio app using mount_gradio_app so I don't need to user the launch function call. I want to hide the "Use via API" on the footer. I try to add app_kwargs={"show_api": False} when calling the mount_gradio_app() and the "Use via API" message still shown on the footer.

### Have you searched existing issues?  🔎

- [X] I have searched and found no existing issues

### Reproduction

```python
import gradio as gr

```


### Screenshot

_No response_

### Logs

_No response_

### System Info

```shell
5.5.0
```


### Severity

Blocking usage of gradio

Hints from issue discussion:
Would you like to submit a PR for this @canytam-krystal ?

Commit message: 3rd Fix: show_api in mount_gradio_app

Patch to review:
diff --git a/.changeset/two-ghosts-punch.md b/.changeset/two-ghosts-punch.md
new file mode 100644
index 0000000000..2cfa0184ca
--- /dev/null
+++ b/.changeset/two-ghosts-punch.md
@@ -0,0 +1,5 @@
+---
+"gradio": patch
+---
+
+fix:Fix: Added support for show_api in mount_gradio_app
diff --git a/gradio/routes.py b/gradio/routes.py
index 6425f82893..8b8031e7a3 100644
--- a/gradio/routes.py
+++ b/gradio/routes.py
@@ -1524,6 +1524,7 @@ def mount_gradio_app(
     path: str,
     server_name: str = "0.0.0.0",
     server_port: int = 7860,
+    show_api: bool = True,
     app_kwargs: dict[str, Any] | None = None,
     *,
     auth: Callable | tuple[str, str] | list[tuple[str, str]] | None = None,
@@ -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.
@@ -1578,6 +1580,7 @@ def read_main():
         )
 
     blocks.dev_mode = False
+    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()


Code review comments:
diff_hunk: @@ -1578,6 +1580,7 @@ def read_main():
         )
 
     blocks.dev_mode = False
+    blocks.show_api = show_api
path: gradio/routes.py
text: @user1:
```suggestion
    if show_api is not None:
        blocks.show_api = show_api
```

diff_hunk: @@ -1524,6 +1524,7 @@ def mount_gradio_app(
     path: str,
     server_name: str = "0.0.0.0",
     server_port: int = 7860,
+    show_api: bool = True,
path: gradio/routes.py
text: @user1:
```suggestion
    show_api: bool | None = None,
```