本地 HTML 文件无法正确加载到 Dash 应用程序中

Local HTML file won't load properly into Dash application

我尝试将本地 html 文件嵌入到基本的 Dash 应用程序中。 我使用了此 link 中的代码并将路径替换为我的本地相对路径(dash 应用程序与 html 本地页面位于同一文件夹中)

html.Iframe(src="random_example.html",
            style={"height": "1067px", "width": "100%"})

但这是我得到的结果:

您可以将 html 文件放在 assets 文件夹中并像这样引用它:

import dash
import dash_html_components as html

app = dash.Dash(__name__)

app.layout = html.Div(
    children=[
        html.Iframe(
            src="assets/random_example.html",
            style={"height": "1067px", "width": "100%"},
        )
    ]
)

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