Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RootPath not properly working from Gradio version 4.21.0 and onward (including 5.16.0) when using gr.mount and FastAPI directly #10590

Open
1 task done
jayteaftw opened this issue Feb 13, 2025 · 0 comments
Labels
bug Something isn't working cloud Issues that only happen when deploying Gradio on cloud services

Comments

@jayteaftw
Copy link

jayteaftw commented Feb 13, 2025

Describe the bug

root_path is not properly working when mounting gradio application to fastapi as theme.css becomes unaccessible. Looks like how the theme file is being accessed changed from 4.20.1 to 4.21.0. Interestingly, when deployed and used with localhost, it works an intended on gradio on 5.16.0, only when deployed on a https webserver its not able to find the theme.css. However neither the 4.20.1, 4.21.0 or 5.16.0 work properly as they all show 404 connection loss when actually submitting a job. With gradio==5.16.0 and no FastAPI mount the program works as intended but I need to mount it using FastAPI to get use external authentication which is absolutely neccessary.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr
from fastapi import FastAPI

demo = gr.Interface(
    fn=greet,
    inputs=["text", "slider"],
    outputs=["text"],
)

ROOT_PATH = '/chat/tech-library'
app = FastAPI(root_path = ROOT_PATH)
app = gr.mount_gradio_app(app, demo, path="/app")
uvicorn --host "0.0.0.0"  --proxy-headers --port 7860 serve:app

Screenshot

Gradio==4.21.0 to gradio==5.16.0
Image

Image

Gradio==4.20.1
Image

gradio==5.16.0 w/ Localhost
Image

gradio==5.16.0 w/o FastAPI
ENV GRADIO_SERVER_NAME="0.0.0.0"
GRADIO_ROOT_PATH="/chat/tech-library"

import gradio as gr
from fastapi import FastAPI

demo = gr.Interface(
    fn=greet,
    inputs=["text", "slider"],
    outputs=["text"],
)
demo.launch()

Image

gradio==5.16.0 w/ FastAPI but w/o RootPath
Image

Logs

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 5.16.0
gradio_client version: 1.7.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 4.8.0
audioop-lts is not installed.
fastapi: 0.115.8
ffmpy: 0.5.0
gradio-client==1.7.0 is not installed.
httpx: 0.28.1
huggingface-hub: 0.28.1
jinja2: 3.1.5
markupsafe: 2.1.5
numpy: 1.26.4
orjson: 3.10.15
packaging: 24.2
pandas: 2.2.3
pillow: 11.1.0
pydantic: 2.10.6
pydub: 0.25.1
python-multipart: 0.0.20
pyyaml: 6.0.2
ruff: 0.9.6
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.45.3
tomlkit: 0.13.2
typer: 0.15.1
typing-extensions: 4.12.2
urllib3: 2.3.0
uvicorn: 0.34.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2024.9.0
httpx: 0.28.1
huggingface-hub: 0.28.1
packaging: 24.2
typing-extensions: 4.12.2
websockets: 14.2

Severity

Blocking usage of gradio

@jayteaftw jayteaftw added the bug Something isn't working label Feb 13, 2025
@abidlabs abidlabs added the cloud Issues that only happen when deploying Gradio on cloud services label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cloud Issues that only happen when deploying Gradio on cloud services
Projects
None yet
Development

No branches or pull requests

2 participants