def runserver(host, port): """Run 2L services.""" from app.app import run_server click.echo(('[2L] The services running at: ' 'http://{0}:{1}/').format(host, port)) run_server(host, port)
dict(l=25, r=25, t=50, b=50), 'template': 'ggplot2', 'title': go.layout.Title(text="ROC curve", xref="paper", x=0), 'annotations': [ go.layout.Annotation( x=0.75, y=0.25, xref="paper", yref="paper", text=f"AUC: {auc:.3f}<br>(area under<br>the curve)", showarrow=False, font=dict(size=14), xanchor="center", yanchor="middle", align="center", bgcolor='rgba(255, 255, 255, 0.8)', borderpad=3, ) ] } return go.Figure(data=data, layout=fig_layout) if __name__ == '__main__': app.title = "Diagnostic tests" app.layout = layout app.run_server(debug=True)
################################################################################ ## Main Index app.layout = html.Div( [dcc.Location(id="url", refresh=False), html.Div(id="page-content")]) def create_index_page(): """ Dynamically create links for all app pages """ links = [] for page in pages: links.append(dcc.Link("Go to Page " + page, href="/pages/" + page)) links.append(html.Br()) return links index_page = create_index_page() @app.callback(Output("page-content", "children"), [Input("url", "pathname")]) def display_page(pathname): if pathname == "/": return index_page return page_lookup(pathname) if __name__ == "__main__": app.run_server(debug=True, host="0.0.0.0")
URL = dcc.Location(id="url") Content = html.Div(id="page-content", children=[]) app.layout = html.Div( [ URL, SidebarLinks, Content ] ) @app.callback(Output("page-content", "children"), [Input("url", "pathname")]) def render_page_content(pathname): if pathname == "/count-overview": return CountCards elif pathname == "/score-overview": return ScoreCards elif pathname == "/page-2": return html.P("Oh cool, this is page 2!") return dbc.Jumbotron( [ html.H1("404: Not found", className="text-danger"), html.Hr(), html.P(f"The pathname {pathname} was not recognised..."), ] ) if __name__ == '__main__': app.run_server(port= 9000, debug = True)
def display_page(pathname): if pathname in ["/", "/page-5"]: return app5.layout elif pathname == "/page-2": return app1.layout elif pathname == "/page-3": return app3.layout elif pathname == "/page-4": return app4.layout elif pathname == "/page-1": return app2.layout else: return "404: Not found" @app.callback( Output("collapse", "is_open"), [Input("toggle", "n_clicks")], [State("collapse", "is_open")], ) def toggle_collapse(n, is_open): if n: return not is_open return is_open if __name__ == "__main__": app.run_server(debug = isdev, host = "0.0.0.0", port = run_port, dev_tools_hot_reload = isdev )
{%scripts%} {%renderer%} </footer> </body> </html> ''' #APP LAYOUT DIV app.layout = html.Div( [dcc.Location(id='url', refresh=False), html.Div(id='page-content')]) #CHANGE PAGE DEPENDING ON PATHNAME @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/': return app1.layout elif pathname == '/apps/app1': return app1.layout else: return app_credits.layout #START THE SERVER server = app.server if __name__ == '__main__': app.run_server(port=8050, host='0.0.0.0', debug=True)
elif pathname == "/signup": import signupPage return signupPage.layout elif pathname == "/selector": import selectorPage return selectorPage.layout elif pathname == "/accountdetails": import accountDetails return accountDetails.layout elif pathname == "/wardrobe": import wardrobePage return wardrobePage.layout else: return loginPage.layout if __name__ == "__main__": app.run_server( debug=True, host="0.0.0.0", port="8080", )
) # For more explanation, see: # Plotly Dash User Guide, URL Routing and Multiple Apps # https://dash.plot.ly/urls app.layout = html.Div([ dcc.Location(id='url', refresh=False), navbar, dbc.Container(id='page-content', className='mt-4'), html.Hr(), # horizontal rule footer ]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/': return index.layout elif pathname == '/predictions': return predictions.layout elif pathname == '/insights': return insights.layout elif pathname == '/process': return process.layout else: return dcc.Markdown('## Page not found') if __name__ == '__main__': app.run_server() #debug=True
from apps import app1, app2 app.layout = html.Div( [dcc.Location(id='url', refresh=False), html.Div(id='page-content')]) index_page = html.Div([ dcc.Link('App1', href='/apps/app1'), html.Br(), dcc.Link('App2', href='/apps/app2'), ]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/apps/app1': return app1.layout elif pathname == '/apps/app2': return app2.layout else: # return '404' return index_page # if __name__ == '__main__': # app.run_server(debug=True) if __name__ == "__main__": # app.run_server(debug=True, port=5001) app.run_server(host='0.0.0.0', port=8080, debug=True)
from apps import home, livedata app.layout = html.Div([ html.Div([ html.Div([html.H3('Heading for Multi Page App')]), dcc.Link('Home', href='/', style={'paddingRight': '10px'}), dcc.Link('Stats', href='/stats', style={'paddingRight': '10px'}), dcc.Link('Live', href='/live', style={'paddingRight': '10px'}), dcc.Location(id='url', refresh=False) ], className='navbar navbar-dark sticky-top mt-5'), dbc.Container(id='main-content', children='Main', className='', fluid=True) ], className='') @app.callback(Output('main-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/': return home.layout elif pathname == '/stats': return html.H3('Comming soon') elif pathname == '/live': return livedata.layout else: return html.H3('Page not found 404') if __name__ == '__main__': app.run_server(debug=True, host='0.0.0.0')
from app import app from layout.layout import layout from routes import render_page_content from layout.sidebar_callbacks import toggle_collapse, toggle_classname from settings.config import APP_HOST, APP_PORT, APP_DEBUG, DEV_TOOLS_PROPS_CHECK app.layout = layout if __name__ == "__main__": app.run_server(host=APP_HOST, port=APP_PORT, debug=APP_DEBUG, dev_tools_props_check=DEV_TOOLS_PROPS_CHECK)
''' if pathname==None: return '/' if '/' in pathname: if pathname=='/': return pathname return pathname.split('/')[1].strip() @app.callback( Output('slide-count','label'), [Input('current-slide','children')] ) def update_slide_count(current_slide): '''shows the current slide number out of the total''' total = len(slide_order) current = slide_dict()[current_slide] + 1 return '{}/{}'.format(current,total) if __name__=='__main__': app.run_server( port=8050, host = 'localhost', debug=True, )
]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): # print(pathname) if pathname == '/support/A1_welcome': return A1_welcome.layout elif pathname == '/support/A2_temperature': return A2_temperature.layout # elif pathname == '/support/A3_salinity': # return A3_salinity.layout elif pathname == '/support/A4_currents': return A4_currents.layout # elif pathname == '/support/A5_energy': # return A5_energy.layout # elif pathname == '/support/A6_waves': # return A6_waves.layout elif pathname == '/support/A7_shipRouteOptimization': return A7_shipRouteOptimization.layout # elif pathname == '/support/A8_oceanSurface': # return A8_oceanSurface.layout # elif pathname == '/support/A9_particleTracking': # return A9_particleTracking.layout else: return '404' if __name__ == '__main__': app.run_server(debug=True, use_reloader = False)
CONTENT_STYLE = { "margin-left": "18rem", "margin-right": "2rem", "padding": "2rem 1rem", } content = html.Div(id="page-content", style=CONTENT_STYLE) app.layout = html.Div( [dcc.Location(id='url', refresh=False), sidebar, content]) @app.callback(Output("page-content", "children"), [Input("url", "pathname")]) def render_page_content(pathname): if pathname in ["/", "/page-1"]: return overview.layout elif pathname == "/page-2": return ticker_analysis.layout elif pathname == "/page-3": return page3.layout # econ_app.layout elif pathname == "/page-4": return page3.layout return dbc.Jumbotron([ html.H1("404: Not found", className="text-danger"), html.Hr(), html.P(f"The pathname {pathname} was not recognised..."), ]) if __name__ == "__main__": app.run_server(debug=True, port=4020)
from app import app if __name__ == '__main__': app.run_server(debug=True, host='0.0.0.0', port=8080)
from dash.dependencies import Input, Output import dash_core_components as dcc import dash_html_components as html from app import app from apps import app1, app2 app.layout = html.Div([ dcc.Location(id='url', refresh=False), html.Div(id='page-content') ]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/apps/app1': return app1.layout elif pathname == '/apps/app2': return app2.layout else: return '404' if __name__ == '__main__': app.run_server(debug=True)
className="mb-5" ) app.layout = html.Div([ dcc.Location(id='url', refresh=False), dashboard, html.Div(id='page-content') ]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/basic/graph1': return basic1.layout elif pathname == '/basic/graph2': return basic2.layout elif pathname == '/basic/graph3': return basic3.layout elif pathname == '/advanced/graph1': return advanced1.layout elif pathname == '/forecast/demand/randomforest': return predict_demand_randomforest.layout elif pathname == '/forecast/demand/average': return predict_demand_average.layout else: return home.layout if __name__ == '__main__': app.run_server(debug=True, host='192.168.1.30', port=2424)
def dash(self, df, mode): y_variable = self.y_variable g = plotly_graphs() y_variables = [col for col in df.columns if '_impact' in col] original_variables = [col for col in df.columns if not '_impact' in col] original_variables = [col for col in original_variables if not '_rescaled' in col] array = [] PAGE_SIZE = 10 row_number = 1 # y_variable = "predict" columns = ['index', '0', '1', '2', '3', '4'] dat = [] available_columns = list(df.columns) external_stylesheets = ['https://codepen.io/rab657/pen/LYpKraq.css', { 'href': 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css', 'rel': 'stylesheet' } ] # app = JupyterDash(__name__, external_stylesheets=external_stylesheets) app.title = "explainX.ai - Main Dashboard" PLOTLY_LOGO = "https://images.plot.ly/logo/new-branding/plotly-logomark.png" menu = dbc.Row( [ dbc.Col(dbc.NavItem(dbc.NavLink("Global Explanation", href="/apps/global_explanation")), style={'width':"200px",'fontSize':'12px'}), dbc.Col(dbc.NavItem(dbc.NavLink("Local Explanation", href="/apps/local_explanation")), style={'width':"200px",'fontSize':'12px'}), dbc.Col(dbc.NavItem(dbc.NavLink("Feature Interaction", href="/apps/feature_interaction")), style={'width':"200px",'fontSize':'12px'}), dbc.Col(dbc.NavItem(dbc.NavLink("Distributions", href="/apps/distribution")), style={'width':"200px",'fontSize':'12px'}), ], no_gutters=True, className="ml-auto flex-nowrap mt-3 mt-md-0", align="center" ) navbar = dbc.Navbar( [ html.A( # Use row and col to control vertical alignment of logo / brand dbc.Row( [ dbc.Col(html.Img(src=PLOTLY_LOGO, height="30px")), dbc.Col(dbc.NavbarBrand("explainX.ai", className="ml-2", style={'fontSize':'12px','color':'black'})), ], align="center", no_gutters=True, ), href="https://www.explainx.ai", ), dbc.NavbarToggler(id="navbar-toggler"), dbc.Collapse(menu, id="navbar-collapse", navbar=True), ], color="light", dark=True, ) # add callback for toggling the collapse on small screens @app.callback( Output("navbar-collapse", "is_open"), [Input("navbar-toggler", "n_clicks")], [State("navbar-collapse", "is_open")], ) def toggle_navbar_collapse(n, is_open): if n: return not is_open return is_open @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/apps/global_explanation': return global_explanation.global_explanation(original_variables) elif pathname == '/apps/feature_interaction': return feature_interaction.layout_interaction(original_variables, y_variables) elif pathname == '/apps/distribution' : return distribution.layout_distribution(original_variables) elif pathname == '/apps/local_explanation': return local_explanation.layout_local(original_variables,columns,df.columns) else: return welcome_message welcome_message= html.Div( [ html.H1("Welcome to ExplainX"), html.H3("Click on one of the tabs above to start explaining.") ] ) app.layout = html.Div([ navbar, html.Div([ dbc.Card( [ dbc.CardHeader( html.H2( dbc.Button( "Analyze using SQL", id="collapse-button-2", color="link", style={'fontSize': '14px'}) ) ), dbc.Collapse(html.Div([ html.Div(dcc.Input( id='input-on-submit', type='text', # placeholder="SELECT * FROM df", value="SELECT * FROM df", style={'height': '200px', 'width': '700px', 'fontSize': '15px'})), html.Button('Execute Query', id='submit-val', n_clicks=1), html.Div(id='sql-query-button', children='Enter a value and press submit', style={'display': 'none'} ) ], style={'marginTop': 0}), id="collapse-2"), ] ), ], style=style4), html.Div([ dbc.Card( [ dbc.CardHeader( html.H2( dbc.Button( "View Your Data", id="collapse-button", color="link", style={'fontSize': '14px'}) ) ), dbc.Collapse(html.Div([ html.H4('', style=style1), html.Div([ dash_table.DataTable( id='datatable-interactivity', columns=[ {"name": i, "id": i, "deletable": False, "selectable": True} for i in df.columns ], # data=df.to_dict('records'), editable=True, sort_mode="multi", # selected_columns=[], # selected_rows=[], # page_action="native", page_current=0, page_size=PAGE_SIZE, row_selectable='multi', page_action='custom', style_table=style2, style_header=style3, style_cell={ "font-family": "Helvetica, Arial, sans-serif", "fontSize": "11px", 'width': '{}%'.format(len(df.columns)), 'textOverflow': 'ellipsis', 'overflow': 'hidden', 'textAlign': 'left', 'minWidth': '180px', 'width': '180px', 'maxWidth': '180px', }, css=[ { 'selector': '.dash-spreadsheet td div', 'rule': ''' line-height: 15px; max-height: 20px; min-height: 20px; height: 20px; display: block; overflow-y: hidden; ''' }]) ]) ], style={'marginTop': 0}), id="collapse"), ] ), ], style=style4), #Pages Data html.Div([ dcc.Location(id='url', refresh=False), html.Div(id='page-content') ]) # end of collapsable div ], style=style40) #Navigation #Data Interactivity @app.callback( Output('datatable-interactivity', 'data'), [Input('datatable-interactivity', "page_current"), Input('datatable-interactivity', "page_size")]) def update_table(page_current, page_size): return df.iloc[ page_current * page_size:(page_current + 1) * page_size ].to_dict('records') #Collapse-Toggle @app.callback( Output("collapse", "is_open"), [Input("collapse-button", "n_clicks")], [State("collapse", "is_open")], ) def toggle_collapse(n, is_open): if n: return not is_open return is_open #Collapse-Toggle 2 @app.callback( Output("collapse-2", "is_open"), [Input("collapse-button-2", "n_clicks")], [State("collapse-2", "is_open")], ) def toggle_collapse(n, is_open): if n: return not is_open return is_open #SQL - Data Input Callback @app.callback( dash.dependencies.Output('sql-query-button', 'children'), [dash.dependencies.Input('submit-val', 'n_clicks')], [dash.dependencies.State('input-on-submit', 'value')]) def update_output(n_clicks, value): sql_query = f'{value}' return sql_query # value1 = 'SELECT * FROM df' # if n_clicks: # else: # return value1 #What-If Form CallBack @app.callback( Output('place_form_here', 'children'), [ # Input('submit-button-state', 'n_clicks'), Input('row_number','value')]) def create_what_if_form(row_number): x = what_if() i = 0 if type(row_number) == type(1): i = row_number array = df[i:i + 1] array1 = array impact_variables = [col for col in array if '_impact' in col] for col in impact_variables: array1.drop([col], axis=1, inplace=True) # features = [col for col in array if not '_impact' in col] features= list(self.param["columns"]) features.append("y_prediction") features.append("y_actual") form = x.what_if_form(array1, features) return form """ change this. Take input from what-if form. """ # Local Feature Impact Graph @app.callback( [Output('local_feature_impact', "figure"), Output('local_message_1', "children"), Output('local_message_2', "children"), Output('local_message_3', "children")], self.callback_input) def update_impact_graph(*values): changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0] # if 'submit-button-state' in changed_id: # use values to construct a dataframe # find prediction and shap values. df= pd.DataFrame([values[:-1]]) df.columns= self.param["columns"] # print(df) #find prediction and impact values first here please. array = self.calculate_prediction_shap(df) figure, dat = g.feature_impact_old(array) # print(dat) message = self.insights.insight_2_local_feature_impact(dat) return figure, message[0], message[1], message[2] # else: # df2 = self.df[0:1] # figure, dat = g.feature_impact_old(df2) # # print(dat) # message = self.insights.insight_2_local_feature_impact(dat) # return figure, message[0], message[1], message[2] # Prototypical Analysis """ Change this. Take input from what-if from """ @app.callback( Output(component_id='prototype_data', component_property='data'), [Input(f[0], f[1])for f in self.prototype_array]) def update_table(*values): changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0] if 'btn-nclicks-1' in changed_id: #get x variables and prediction column from the data df_row = pd.DataFrame([values[:-1]]) df_row.columns = self.param["columns"] # find prediction and impact values first here please. df_row = self.calculate_prediction(df_row) df_selected= df[list(self.param["columns"])+ [self.param["y_variable_predict"]]] row_number = len(df_selected) df_selected.loc[row_number] = df_row.values[0] p = protodash() p.preprocess_data(df_selected, self.param["y_variable_predict"]) dfs, sample_row = p.find_prototypes(row_number) dat = dfs.T.reset_index() print("sample row columns") sample_row = sample_row.to_frame() sample_row.rename(columns={sample_row.columns[0]: "orig"}, inplace=True) sample_row.reset_index(inplace=True) print(sample_row.columns) dat = pd.merge(dat, sample_row, on=['index'], how='left') dat['orig'] = dat['orig'].astype(float) for i in list(dat.columns): dat[str(i) + '_color'] = np.nan if i != 'index': dat[i] = dat[i].astype(float) dat[str(i) + '_color'] = dat[str(i) + '_color'].astype(float) dat[str(i) + '_color'] = np.where(dat['orig'] == dat[i], 1, 0) dat.drop(["index_color","orig_color"], axis=1, inplace=True) dat = dat.to_dict('records') return dat else: return [] # Global Feature Importance @app.callback( [Output('global_feature_importance', "figure"), Output('global_message_1', "children"), Output('global_message_2', "children"), Output('global_message_3', "children"), Output('global_message_4', "children"), Output('global_message_5', "children")], [Input('sql-query-button', 'children'), Input('xaxis-column-test-2', 'value')]) def update_graphs(sql_query, value ): g = plotly_graphs() graph_type = "feature_importance" dff = self.caching_data_manager(df, sql_query, graph_type, g.feature_importance) message = self.insights.insight_1_feature_imp(dff) figure = g.feature_importance_graph(dff) if len(message) == 4: return figure, message[0], message[1], message[2], message[3], "" return figure, message[0], message[1], message[2], message[3], message[4] # Global Feature Impact @app.callback( [Output('global_feature_impact', "figure"), Output('message_1', "children"), Output('message_2', "children"), Output('message_3', "children")], [Input('sql-query-button', 'children'), Input('xaxis-column-test-2', 'value')]) def update_graphs(sql_query,value): g = plotly_graphs() graph_type = "feature_impact" df3 = self.caching_data_manager(df, sql_query, graph_type, g.feature_impact) figure = g.feature_impact_graph(df3) message = self.insights.insight_2_global_feature_impact(df3) return figure, message[0], message[1], message[2] # Partial Dependence Plot Graph @app.callback( Output('indicator-graphic', 'figure'), [Input('xaxis-column', 'value'), Input('yaxis-column', 'value'), Input('third-axis', 'value'), Input('sql-query-button', 'children')]) def update_graph(xaxis_column_name, yaxis_column_name, third_axis_name, sql_query): g = plotly_graphs() graph_type = 'pdp' df3 = self.caching_data_manager(df, sql_query, graph_type, g.partial_dependence_plot) fig = g.pdp_plot(df3, df3[xaxis_column_name], df3[yaxis_column_name], df3[third_axis_name]) return fig # Summary Plot @app.callback( Output('summary_plot', 'figure'), [Input('sql-query-button', 'children'), Input('xaxis-column-test', 'value')]) def update_graph2(sql_query, value): g = plotly_graphs() graph_type = 'summary_plot' df3 = self.caching_data_manager(df, sql_query, graph_type, g.summary_plot) print(df3) fig = g.summary_plot_graph(df3) return fig # Distributions @app.callback( Output('indicator-graphic2', 'figure'), [Input('xaxis-column-name', 'value'), Input('plot_type', 'value'), Input('sql-query-button', 'children'), ]) def update_graph2(xaxis_column_name, plot_type, sql_query): graph_type = 'filtered_df' df3 = self.caching_data_manager(df, sql_query, graph_type) cat_variables = [] num_variables = [] for i in original_variables: if df[i].dtype == 'object': cat_variables.append(i) else: num_variables.append(i) if plot_type == "Histogram": # group_labels = ['xxaxis_column_name'] return px.histogram(df3, x=xaxis_column_name, marginal="box") else: for i in cat_variables: return px.violin(df3, x=xaxis_column_name, box=True, points='all') else: return px.violin(df3, y=xaxis_column_name, box=True, points='all', ) # Multi Level EDA @app.callback( Output('multi_level_eda', 'figure'), [Input('x_axis', 'value'), Input('y_axis', 'value'), Input('size', 'value'), Input('color', 'value'), Input('facet_col', 'value'), Input('facet_row', 'value'), Input('sql-query-button', 'children'), ] ) def multi_level(x_axis, y_axis, size, color, facet_col, facet_row, sql_query): graph_type = 'filtered_df' df3 = self.caching_data_manager(df, sql_query, graph_type) return px.scatter(df3, x=x_axis, y=y_axis, size=size, color=color, facet_col=facet_col, facet_row=facet_row, facet_col_wrap=4) # Port Finder port = 8080 debug_value= False if mode == "inline": try: app.run_server(mode="inline", port=port,debug=debug_value,dev_tools_ui=debug_value,dev_tools_props_check=debug_value) except: port= self.find_free_port() app.run_server(mode="inline",port=port,debug=debug_value,dev_tools_ui=debug_value,dev_tools_props_check=debug_value) else: try: app.run_server(host='0.0.0.0', port=port,debug=debug_value,dev_tools_ui=debug_value,dev_tools_props_check=debug_value) except: # try different ip in case 0.0.0.0 does not work try: try: port=self.find_free_port() app.run_server(host='0.0.0.0', port=port,debug=debug_value,dev_tools_ui=debug_value,dev_tools_props_check=debug_value) except: port = self.find_free_port() app.run_server(host='0.0.0.0', port=port,debug=debug_value,dev_tools_ui=debug_value,dev_tools_props_check=debug_value) except: try: port = self.find_free_port() app.run_server(host='127.0.0.1', port=port,debug=debug_value,dev_tools_ui=debug_value,dev_tools_props_check=debug_value) except: print("Please restart Jupyter Notebook or Python IDE.") return False try: self.increate_counter() except: pass return True
page_name = app.strip_relative_path(pathname) if not page_name: # getting executed twice once for page and once for link home return pages.home.layout() elif page_name == "census": #return return pages.census.layout() elif page_name == "orders": #return return pages.orders.layout() elif page_name == "authorizations": #return return pages.authorizations.layout() elif page_name == "billing": return pages.billing.layout() elif page_name == "qa": return elif page_name == "OrderProcessing": return pages.OrderProcessing.layout() elif page_name == "VisitPlanning": return pages.VisitPlanning.layout() elif page_name == "bd": return #return pages.bd.layout() else: return "404" if __name__ == "__main__": app.run_server(debug=True, threaded=True)
from dash.dependencies import Input, Output import dash_core_components as dcc import dash_html_components as html from app import app server = app.server from apps import world, country app.layout = html.Div( [dcc.Location(id='url', refresh=False), html.Div(id='page-content')]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == 'apps/country': return country.layout else: return world.layout if __name__ == '__main__': app.run_server()
vertical=True, pills=True, ), ], style=SIDEBAR_STYLE, ) content = html.Div(id="page-content", style=CONTENT_STYLE) app.layout = html.Div([dcc.Location(id="url"), sidebar, content]) @app.callback(Output("page-content", "children"), [Input("url", "pathname")]) def render_page_content(pathname): if pathname == "/": return fighter_comparison.layout elif pathname == "/ranking": return all_time_ranking.layout elif pathname == "/page-2": return html.P("Oh cool, this is page 2!") # If the user tries to reach a different page, return a 404 message return dbc.Jumbotron([ html.H1("404: Not found", className="text-danger"), html.Hr(), html.P(f"The pathname {pathname} was not recognised..."), ]) if __name__ == "__main__": app.run_server(port=8888, debug=False)
required=False, help='Start server in debug') argparser.add_argument('-j', '--host', required=False, type=str, default=os.getenv('HOST'), help='Server host') argparser.add_argument('-p', '--port', required=False, type=str, default=os.getenv('PORT'), help='Server port') # # Main # if __name__ == '__main__': # Parse args args = argparser.parse_args() debug = args.debug host = args.host port = args.port # Start server app.run_server(debug=debug, host=host, port=port)
# return layout_metasearch else: return noPage # # # # # # # # # # detail the way that external_css and external_js work and link to alternative method locally hosted # # # # # # # # # external_css = [ "https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css", "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css", "//fonts.googleapis.com/css?family=Raleway:400,300,600", "https://codepen.io/bcd/pen/KQrXdb.css", "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css", "https://codepen.io/dmcomfort/pen/JzdzEZ.css" ] for css in external_css: app.css.append_css({"external_url": css}) external_js = [ "https://code.jquery.com/jquery-3.2.1.min.js", "https://codepen.io/bcd/pen/YaXojL.js" ] for js in external_js: app.scripts.append_script({"external_url": js}) if __name__ == '__main__': app.run_server(host='127.0.0.1', port=8085, debug=True)
return is_open @app.callback( Output('bundle-manager-modal-totalcost', 'is_open'), [Input('bundle-manager-button-openmodal-totalcost', 'n_clicks'), Input('bundle-manager-button-closemodal-totalcost', 'n_clicks')], [State('bundle-manager-modal-totalcost', 'is_open')] ) def open_modal(n1, n2, is_open): if n1 or n2: return not is_open return is_open @app.callback( Output('bundle-manager-modal-bundle-performance-details', 'is_open'), [Input('bundle-manager-button-openmodal-bundle-performance-details', 'n_clicks'), Input('bundle-manager-button-closemodal-bundle-performance-details', 'n_clicks')], [State('bundle-manager-modal-bundle-performance-details', 'is_open')] ) def open_modal(n1, n2, is_open): if n1 or n2: return not is_open return is_open if __name__ == "__main__": app.run_server(host="127.0.0.1",debug=True, port = 8049)
# define the layout of app app.layout = html.Div([ dcc.Tabs(id='tabs', value='tab-a', children=[ dcc.Tab(label='Analysis', value='tab-a'), dcc.Tab(label='Moving Average', value='tab-1'), dcc.Tab(label='Exponential Smoothing', value='tab-2'), dcc.Tab(label='ARIMA', value='tab-3') ]), html.Div(id='tabs-content') ]) # decorator which will ensure that the updation function is called when the input changes @app.callback(Output('tabs-content', 'children'), [Input('tabs', 'value')]) # function which updates the dashboard based on the inputs def render_content(tab): if tab == 'tab-a': return tab_a.layout elif tab == 'tab-1': return tab1.layout elif tab == 'tab-2': return tab2.layout elif tab == 'tab-3': return tab3.layout if __name__ == '__main__': app.run_server(host='127.0.0.1', port='8050', debug=True)
in_navbar=True, label="Accounts", right=True), ], brand="Finance Tool", fluid=True) app.layout = html.Div([ navbar, dcc.Location(id='url', refresh=False), html.Div(id='page-content') ]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/explore': return explore.layout elif pathname == '/test': return test_app.layout elif pathname == '/analyze': return analyze.layout else: return '404' if __name__ == "__main__": app.run_server(debug=True, port=config['app']['port'], host=config['app']['host'])
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from app import app import app1_home import app2_sentiment app.layout = html.Div( [dcc.Location(id='url', refresh=False), html.Div(id='page-content')]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/home': return app1_home.layout elif pathname == '/sentiment': return app2_sentiment.layout else: return app1_home.layout if __name__ == '__main__': app.run_server(debug=True, port=8552) # app.run_server(debug=True, host='0.0.0.0') server = app.server
from app import app from callbacks import left_column from callbacks import right_column if __name__ == "__main__": app.run_server(debug=True, dev_tools_silence_routes_logging=True)
# Update page callback @app.callback(Output("page-content", "children"), [Input("url", "pathname")]) def display_page(pathname): """Update the lexicon page to display.""" if pathname in ["/"] + [url_name for url_name in lexical_field_to_url_name.values()]: return build_layout(pathname) else: return noPage external_css = [ "https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css", "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css", "//fonts.googleapis.com/css?family=Raleway:400,300,600", "https://codepen.io/bcd/pen/KQrXdb.css", "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css", "https://codepen.io/dmcomfort/pen/JzdzEZ.css", ] for css in external_css: app.css.append_css({"external_url": css}) external_js = ["https://code.jquery.com/jquery-3.2.1.min.js", "https://codepen.io/bcd/pen/YaXojL.js"] for js in external_js: app.scripts.append_script({"external_url": js}) if __name__ == "__main__": app.run_server(debug=False)
State('session','modified_timestamp')]) def display_dashboards(value,layout,key,data,ts): hidden=True if ts is None: data={} data['index_page']=index_page return index_page,'index_page',data,hidden else: if(value!='index_page'): temp=data.get(value,router_dash(value)) data[value]=temp hidden=False else: temp=index_page if (data[key]): data[key]=layout return temp,value,data,hidden if __name__ == '__main__': app.run_server(debug=True,port=5555)
elif pathname == '/Carbon': return Carbon.layout elif pathname == '/Experiential': return Experiential.layout elif pathname == '/Hydrology': return Hydrology.layout elif pathname == '/ImplementationCost': return ImplementationCost.layout elif pathname == '/Infrastructure': return Infrastructure.layout elif pathname == '/PeopleHouses': print(season) return PeopleHouses.layout elif pathname == '/Recreational': return Recreational.layout elif pathname == '/RegionalEconomy': return RegionalEconomy.layout else: return html.Div( children=[ html.Div( className='ui header', children=['404'] ), html.P('File not found.') ]) if __name__ == '__main__': app.run_server(host='0.0.0.0', debug=False, port=8050)
app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app.layout = html.Div(children=[ dash_table.DataTable( id='datatable', columns=[{ "name": i, "id": i, "deletable": True } for i in df.columns], data=df.to_dict("rows"), #editable=True, filtering=True, sorting=True, sorting_type="multi", row_selectable="single", row_deletable=True, selected_rows=[], n_fixed_rows=1, style_table={ 'maxHeight': '700', # 'overflowX': 'scroll', 'overflowY': 'scroll', }, ), ]) if __name__ == '__main__': app.run_server(debug=True, port=8070)
"margin-top": "2rem" }), html. H4("* Default sorting: by Contribution to Overall Performance Difference", style={ "font-size": "0.8rem", "color": "#919191", "padding-top": "1rem", "margin-bottom": "-1rem" }), html.Div([ dashtable_lv3(data_lv4, 'Sub Category', 'dashtable_physician_lv3', 0) ], id="drill_physician_lv3", style={"padding": "1rem"}) ], style={"max-height": "120rem"}), ]), className="mb-3", style={ "box-shadow": "0 4px 8px 0 rgba(0, 0, 0, 0.05), 0 6px 20px 0 rgba(0, 0, 0, 0.05)", "border": "none", "border-radius": "0.5rem" }) if __name__ == "__main__": app.run_server(host="127.0.0.1", debug=True)
style={"margin": "0%"}, ) @app.callback(Output("tab_content", "children"), [Input("tabs", "value")]) def render_content(tab): if tab == "define": return define_front.layout elif tab == "analyze": return analyze_front.layout elif tab == "model": return model_front.layout elif tab == "tune": return tune_front.layout elif tab == "predict": return predict_front.layout else: message = html.Div([ dcc.Markdown( dedent(f''' > #### Under development > ###### Head to [pymach](http://www.github.com/gusseppe/pymach) ''')) ],className='two columns indicator') return message if __name__ == "__main__": app.run_server(host='0.0.0.0', debug=True, port=9088)