Coder Social home page Coder Social logo

Comments (2)

snps-ravinu avatar snps-ravinu commented on June 3, 2024 1

Thanks @freddyaboulton, to update on the issue, I was using allowed paths, but the issue was with the path I was giving in the img src, my ui mount path was "/ui", so I had to insert "/ui" to the src path and that resolved the issue

from gradio.

freddyaboulton avatar freddyaboulton commented on June 3, 2024

Hi @snps-ravinu ! This is expected. Gradio can't serve arbitrary files from your computer/server for security reasons. To serve a file from outside the app directory, use the allowed_paths argument of mount_gradio_app.

The following works for me. Note that I am running this from the same directory as the app.py. If I was running it from a different directory, I would have to use the full path to the static dir in the markdown component.

import gradio as gr
from fastapi import FastAPI

with gr.Blocks() as demo:
    gr.Markdown("<img src='/file=static/cheetah.jpg' width='300px'>")


app = FastAPI()

app = gr.mount_gradio_app(app=app, blocks=demo, path="/",
    allowed_paths=["<full-path-to-static-dir>/static"])

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, port=7860)

from gradio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.