MFTS
MFTS

Reputation: 35

Local png image not loading

I'm doin a small dashboard for the company I work for and I want to add the logo on the page. In theory, everything looks fine but when I run the app, the image doesn't load even though the name of the file is the same as the one on the code.

I've tried to move the image to a separate directory, as well as having in it at the same level as the app but none of this seems to work

 if __name__ == '__main__':

    external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

    app = dash.Dash(__name__,external_stylesheets=external_stylesheets)

    app.layout=html.Div(className='container',children=[ 
            html.Img(src='/logo/logo.png')])

    app.run_server(debug=True)

I expect the image to appear whenever I load the app but the only thing that appears is the "broken image" icon on screen. Like I said, I tried changing the directory and having the image on root but still doesn't load.

Upvotes: 3

Views: 6036

Answers (1)

coralvanda
coralvanda

Reputation: 6596

Check out this post.

I tested a simple local example using the file in the same directory as my .py file running the Dash app with image_filename = os.path.join(os.getcwd(), 'picture.jpg') and it worked perfectly.

Upvotes: 4

Related Questions