Hello everyone, I have a Flask application and a Dash application, but I can’t encapsulate Dash within Flask so that I can use my @login_required decorator. Can someone help me? I’ll leave some example code below
init.py
from flask import Flask, request
from app.dash_app import create_dash_app
def init_app():
app = Flask(__name__)
app.config.from_object('app.config.Config')
with app.app_context():
dash_app = create_dash_app(app)
return app
dash_app.py
import dash
from dash import Dash, html, dcc, callback, Output, Input, dash_table
from flask import Flask
from flask_login import login_required
@login_required
def create_dash_app(server):
dash_app = dash.Dash(__name__, server=server, url_base_pathname='/dash/')
//some code
dash_app.layout = html.Div([
dcc.Store(id="store", data={}),
//code
])
@callback's
def functions:
//code
return dash_app, server
I’ve tried to explain how I’m doing it with the examples above. I would greatly appreciate it if someone could tell me how to make this work, as so far I’m running two separate and not integrated applications.