I want to make a dash app to visualize some networks, stored in a database, according to a user input query. Below I have given my code. The pyvis graph is not showing when I run the Dash server. I can see that the html file is being generated properly, but the box is blank when I run the server. How can I resolve this issue?
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
navbar = dbc.Navbar(
dbc.Container(
dbc.Row(
dbc.Col(
dbc.NavbarBrand(
[
html.Span("Network Explorer", className="ms-2")
],
className="d-flex align-items-center"
),
width="auto"
),
className="w-100",
align="center"
),
fluid=True
),
color="light",
dark=False,
sticky="top",
className="p-2",
)
app.layout = dbc.Container([
navbar,
# First Row: Search Box
dbc.Row([
dbc.Col([
dbc.Card([
dbc.CardBody([
dcc.Textarea(
id='search-input',
placeholder='Enter your search here...',
style={'width': '100%', 'height': 100},
className='mb-3'
),
dbc.Button('Submit Query', id='submit-button', n_clicks=0, color="primary")
])
])
], width=12)
], className='mb-4'),
# Second Row: Network Visualization
dbc.Row([
dbc.Col([
html.Div(id="graph-output", className="mt-4", children=[
html.Iframe(
id='default-iframe',
width="100%",
height="600px"
)
])
])
])
])
@app.callback(
Output("default-iframe", "srcDoc"),
Input("submit-button", "n_clicks"),
State("query-input", "value")
)
def update_output(n_clicks, query):
if not n_clicks or not query:
raise PreventUpdate
subgraph = get_subgraph(query)
graph_html = visualize_subgraph(subgraph)
return (graph_html)
if __name__ == '__main__':
app.run_server(debug=True)