Please help, I am trying to run a dash app inside a flask application as follows and i am trying to pass a FLASK input parameter from HTML Form Page (profile passed as GET) to DASH, can you please let me know how to pass the parameter from FLASK to DASH. I’m getting issue at the resolution {profile} as it says that profile is not defined And, please tell how to send a dataframe as well.
Here’s the code:
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output, State
from dash_extensions import Download
from dash_extensions.snippets import send_data_frame
import plotly.graph_objs as go
import pandas as pd
import numpy as np
from datetime import datetime
from flask import Flask, render_template, redirect
import requests
import json
import pandas as pd
import pandasql as psql
import numpy as np
import re
import time
server = Flask(__name__)
# Instanciate the app
app = dash.Dash(__name__,server=server,url_base_pathname='/dash/')
@server.route("/")
def welcome_form_page():
return render_template("index.html")
@server.route("/loader",methods = ['POST', 'GET'])
def loader_page():
from flask import request
global profile
global url
profile = request.args.get('profile')
url = request.args.get('url')
session['profile'] = profile
#time.sleep(10) - Writing some time consuming query that I have used a preloader here.
print(profile,url)
return redirect('/dash/')
app.layout = html.Div(
children = [
html.Div(
children = [
# Title
html.H6(
children = "Profile Name",
style = {
"textAlign": "center",
"color": "white",
"margin-bottom": "25px"
}
),
# value
html.P(
children = f"{profile}",
style = {
"textAlign": "center",
"color": "orange",
"fontSize": 25
}
)
],
className = "card_container three columns",
id = 'profile'
)
]
)