Embed local image in Dash app with HTTP?

The easiest way is probably to just embed them as base64-encoded data:

using Dash, DashHtmlComponents, Base64
app = dash()
app.layout = 
    html_div([
        html_h1("embedded image", style=(textAlign = "center",)),
        html_img(src="data:image/png;base64,$(open(base64encode, "/path/to/file.png"))"),
    ])
run_server(app, "0.0.0.0", 8080)
3 Likes