mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-05 11:10:03 +08:00
Set gradio api server from env (#6666)
* 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>
This commit is contained in:
parent
51b54b3411
commit
30c9fbb5c7
5
.changeset/odd-garlics-teach.md
Normal file
5
.changeset/odd-garlics-teach.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Set gradio api server from env
|
@ -30,6 +30,7 @@ INITIAL_PORT_VALUE = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
|
||||
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 = (
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user