Dangerous Link Detected When Running Dash Example

Hello,

I am testing this example on how to download a dashboard as an HTML file.

The “Download as HTML” button no longer works under Dash 2.15.0. Since I use identical code in a dashboard to download the HTML file, it would help me to understand how to modify the example to work with the latest version of Dash.

Could someone identify what would need to change to make the example functional?

Thanks!

Does using dcc.Download work any better?

Thanks for the reply. I looked over that documentation yesterday. I couldn’t see how to use dcc.Download to work for this purpose.

Do you know whether/how to make it work for the example?

I have some code that works on a local network on Dash 2.15.0

The app is a bit long and rambling, but the essential components for the download are:

This in the layout:

dcc.Download(id="download-html")

… and a callback that outputs to…

Output("download-html", "data")

… returning this to this output:

        buffer = io.StringIO()
        fig.write_html(buffer)
        html_bytes = buffer.getvalue().encode()
        encoded = b64encode(html_bytes).decode()
        contents = {
            "base64":True,
            "content":encoded,
            "filename":"timeline.html",
        }
        return contents

I must have copied this from somewhere, but regret I don’t know who to give original credit to

2 Likes

Thanks! This solved my issue.