mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Fixes URL resolution on Windows (#3108)
* windows urls * changelog * formatting
This commit is contained in:
parent
04484621c2
commit
431a987d61
@ -4,7 +4,7 @@
|
||||
No changes to highlight.
|
||||
|
||||
## Bug Fixes:
|
||||
No changes to highlight.
|
||||
- Fixes URL resolution on Windows by [@abidlabs](https://github.com/abidlabs) in [PR 3108](https://github.com/gradio-app/gradio/pull/3108)
|
||||
|
||||
## Documentation Changes:
|
||||
- Added a guide on the 4 kinds of Gradio Interfaces by [@yvrjsharma](https://github.com/yvrjsharma) and [@abidlabs](https://github.com/abidlabs) in [PR 3003](https://github.com/gradio-app/gradio/pull/3003)
|
||||
|
@ -261,15 +261,17 @@ class App(FastAPI):
|
||||
else:
|
||||
return FileResponse(blocks.favicon_path)
|
||||
|
||||
@app.head("/file={path:path}", dependencies=[Depends(login_check)])
|
||||
@app.get("/file={path:path}", dependencies=[Depends(login_check)])
|
||||
async def file(path: str, request: fastapi.Request):
|
||||
abs_path = str(utils.abspath(path))
|
||||
@app.head("/file={path_or_url:path}", dependencies=[Depends(login_check)])
|
||||
@app.get("/file={path_or_url:path}", dependencies=[Depends(login_check)])
|
||||
async def file(path_or_url: str, request: fastapi.Request):
|
||||
blocks = app.get_blocks()
|
||||
if utils.validate_url(path):
|
||||
return RedirectResponse(url=path, status_code=status.HTTP_302_FOUND)
|
||||
in_app_dir = utils.abspath(app.cwd) in utils.abspath(path).parents
|
||||
created_by_app = str(utils.abspath(path)) in set().union(
|
||||
if utils.validate_url(path_or_url):
|
||||
return RedirectResponse(
|
||||
url=path_or_url, status_code=status.HTTP_302_FOUND
|
||||
)
|
||||
abs_path = str(utils.abspath(path_or_url))
|
||||
in_app_dir = utils.abspath(app.cwd) in utils.abspath(path_or_url).parents
|
||||
created_by_app = str(utils.abspath(path_or_url)) in set().union(
|
||||
*blocks.temp_file_sets
|
||||
)
|
||||
if in_app_dir or created_by_app:
|
||||
@ -291,7 +293,7 @@ class App(FastAPI):
|
||||
|
||||
else:
|
||||
raise ValueError(
|
||||
f"File cannot be fetched: {path}. All files must contained within the Gradio python app working directory, or be a temp file created by the Gradio python app."
|
||||
f"File cannot be fetched: {path_or_url}. All files must contained within the Gradio python app working directory, or be a temp file created by the Gradio python app."
|
||||
)
|
||||
|
||||
@app.get("/file/{path:path}", dependencies=[Depends(login_check)])
|
||||
|
Loading…
x
Reference in New Issue
Block a user