Open elmuz opened 4 weeks ago
Hi @elmuz - the url is now "<img src='/gradio_api/file=assets/logo.jpg'>"
Hi @freddyaboulton. Thank you for the reply. I can confirm that the toy examples above now works (btw, is it mentioned anywhere about the required /gradio_api/file=
prefix?).
However, I am still having problems with the service behind Nginx. For those apps, simply changing the prefix didn't solve. In particular, I have the containers served at https://{localhost or my.production.site}/myapp
each container has the following file struct
/app
βββ assets
β βββ logo.png
βββ run.py
where WORKDIR /app
is in its dockerfile.
Then I tried with both Markdown and HTML (which work fine in the toy example)
gr.Markdown(f"[![logo](/gradio_api/file/assets/logo.png)]({os.getenv('SITE_URL')})")
gr.HTML("<img src='/gradio_api/file=assets/logo.png'>")
but I get respectively
/usr/share/nginx/html/gradio_api/file/assets/logo.png" failed (2: No such file or directory)
/usr/share/nginx/html/gradio_api/file=assets/logo.png" failed (2: No such file or directory)
I am sure assets/logo.png
exists alongside run.py
.
GRADIO_ROOT_PATH
is set with /myapp
like the last part of its urlGRADIO_ALLOWED_PATHS
and gr.set_static_paths()
which at this point I am not even sure they are needed.Can you sport anything wrong in this? Thank you
@elmuz - can you follow this guide to see if it fixes your issue? https://www.gradio.app/guides/running-gradio-on-your-web-server-with-nginx
Hi sorry for the late reply. The guide doesn't fit my case, which is actually the following. I have a single reverse proxy (nginx docker container) that hosts a static landing page with all the demo pointers. Each demo is a separated docker container.
If I let the demo container exposing port 7860, and navigate localhost:7860
, then I can see the static images. So far so good.
On the contrary, when getting to the demo container via the reverse proxy (e.g.: http://localhost/demo1
) images are not present. Anything else is fine (CSS is working, showing the image via gr.Image()
is working). Moreover, I noticed that if I right-click -> inspect and look for sources this is what the page is looking for:
<img src="/gradio_api/file/assets/logo.png" alt="logo">
However, if I manually edit into <img src="demo1/gradio_api/file/assets/logo.png" alt="logo">
it works. It seems that the path is somehow passed incorrectly.
This is the nginx proxy configuration of our demos that are included in the reverse proxy container:
location /demo1/ {
proxy_pass http://demo1:7860/;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
as mentioned in the guide. But maybe that is not correct in my scenario. Any idea?
Describe the bug
Starting from Gradio 5.x files are not accessible anymore via even if they are in a subfolder of the project root. In particular, the same code that used to work with Gradio 4.x doesn't work anymore with Gradio 5.x.
I have read that the role of
allowed_paths
attribute of theBlock.launch()
as mentioned here. Maybe I have misunderstood the right behavior.Please have a look at the code sample and the screenshots. Can you help me with this? I don't have a workaround at the moment apart from not upgrading.
Have you searched existing issues? π
Reproduction
The following code works fine with Gradio 4.x but does not with Gradio 5.x
For completeness:
Screenshot
Logs
No response
System Info
Severity
Blocking usage of gradio