Skip to content

Commit b19e8ad

Browse files
Switch from root_url to request.url in get_api_call_path() (gradio-app#10877)
* changes * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent 3a3d0d9 commit b19e8ad

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.changeset/public-zoos-obey.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gradio": patch
3+
---
4+
5+
feat:Switch from `root_url` to `request.url` in `get_api_call_path()`

gradio/route_utils.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -384,17 +384,16 @@ def get_api_call_path(request: fastapi.Request) -> str:
384384
"""
385385
queue_api_url = f"{API_PREFIX}/queue/join"
386386
generic_api_url = f"{API_PREFIX}/call"
387+
request_url = str(request.url)
387388

388-
root_url = get_request_url(request)
389-
390-
if root_url.endswith(queue_api_url):
389+
if request_url.endswith(queue_api_url):
391390
return queue_api_url
392391

393-
start_index = root_url.rfind(generic_api_url)
392+
start_index = request_url.rfind(generic_api_url)
394393
if start_index >= 0:
395-
return root_url[start_index : len(root_url)]
394+
return request_url[start_index : len(request_url)]
396395

397-
raise ValueError(f"Request url '{root_url}' has an unkown api call pattern.")
396+
raise ValueError(f"Request url '{request_url}' has an unkown api call pattern.")
398397

399398

400399
def get_root_url(

0 commit comments

Comments
 (0)