Skip to content

Commit

Permalink
Set gradio api server from env (#6666)
Browse files Browse the repository at this point in the history
* Use GRADIO_API_SERVER env

* Format the code

* add changeset

* Use env GRADIO_SHARE_SERVER_ADDRESS as default share_server_address

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
  • Loading branch information
3 people committed Dec 6, 2023
1 parent 51b54b3 commit 30c9fbb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-garlics-teach.md
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:Set gradio api server from env
6 changes: 6 additions & 0 deletions gradio/networking.py
Expand Up @@ -30,6 +30,7 @@
TRY_NUM_PORTS = int(os.getenv("GRADIO_NUM_PORTS", "100"))
LOCALHOST_NAME = os.getenv("GRADIO_SERVER_NAME", "127.0.0.1")
GRADIO_API_SERVER = "https://api.gradio.app/v2/tunnel-request"
GRADIO_SHARE_SERVER_ADDRESS = os.getenv("GRADIO_SHARE_SERVER_ADDRESS")

should_watch = bool(os.getenv("GRADIO_WATCH_DIRS", False))
GRADIO_WATCH_DIRS = (
Expand Down Expand Up @@ -218,6 +219,11 @@ def start_server(
def setup_tunnel(
local_host: str, local_port: int, share_token: str, share_server_address: str | None
) -> str:
share_server_address = (
GRADIO_SHARE_SERVER_ADDRESS
if share_server_address is None
else share_server_address
)
if share_server_address is None:
try:
response = httpx.get(GRADIO_API_SERVER, timeout=30)
Expand Down

0 comments on commit 30c9fbb

Please sign in to comment.