'plotly dash link to local html file

i want to link a local HTML file to a plotly dash table.

from dash import Dash
from dash_table import DataTable
import pandas as pd

df = pd.DataFrame(
    {
        "Links": [
            "<a href='https://www.yahoo.com/' target='_blank'>test</a>",
            "<a href='../folder/file.html' target='_blank'>local html File</a>",
        ]
    }
)

app = Dash(__name__)

app.layout = DataTable(
    id="table",
    data=df.to_dict("records"),
    columns=[
        {"id": "Links", "name": "Job", "presentation": "markdown"},
    ],
    markdown_options={"html": True},
)

if __name__ == "__main__":
    app.run_server()

I expect to open a local HTML file with a link out of the datatable



Solution 1:[1]

ok, a solution is to have a "assets" folder in the same directory a the file which deploys the app! the file (html, png ...) is callable with:

"<a href='/assets/test_dir/test1.html' target='_blank'>local html File</a>",

Solution 2:[2]

import dash_html_components as html

html.A("Link to external site", href='link', target="_blank")

Add this line to your app layout part to open a new window with a hyperlink to another website.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alex
Solution 2 diana18