Hello
I have a multi page dash application where upon loading the application loads to localhost:8050/app
The remaining pages are localhost:8050/app/process, localhost:8050/app/visualize
I was hoping to use the newly added hook option to create a route so that for example if I have the following
@hooks.route(methods=(“GET”,), name=“get-data”, priority=1)
def new_route():
data = {
“status”: “success”
}
return jsonify(data)
- and if the user goes to the link localhost:8050/app/get-data - he / she will only just see that string. However - the app being a multi page application when I go to the link it shows me a page not found Error 404.
Or for a single page application
from flask import jsonify
from dash import hooks
import dash
from dash import html, dcc
import pandas as pd
import plotly.express as px
Sample data
df = pd.DataFrame({
“Category”: [“A”, “B”, “C”],
“Value”: [4, 1, 2]
})
Create a simple bar chart
fig = px.bar(df, x=“Category”, y=“Value”, title=“Sample Bar Chart”)
Initialize the Dash app
app = dash.Dash(name,)
Define the layout
app.layout = html.Div([
html.H1(“Simple Dash Application”),
dcc.Graph(figure=fig)
])
@hooks.route(methods=(“GET”,), name=“get-data”)
def new_route():
data = {
“status”: “success”
}
return jsonify(data)
if name == “main”:
app.run(debug=True)
that route does not do anything.
I think I am doing something fundamentally wrong or I am misunderstanding something. Any suggestions / help?