def start_webservice(local_only=False): dash_apps = _get_apps(is_dash=True, include_dev=True) if dash_apps: for app in dash_apps: _init_app(app, is_dash=True) flask_apps = _get_apps(is_dash=False, include_dev=True) if flask_apps: for app in flask_apps: _init_app(app, is_dash=False) if local_only: _app.run_server(port=8050, debug=False) else: from app_util.logging import setup_logging setup_logging() _app.run_server(host='0.0.0.0', port=8050, debug=False)
else: return '404' @app.callback(Output('user-name', 'children'), [Input('page-content', 'children')]) def cur_user(input1): if current_user.is_authenticated: return html.Div('Usuario Actual: ' + current_user.username) # 'User authenticated' return username in get_id() else: return '' @app.callback(Output('logout', 'children'), [Input('page-content', 'children')]) def user_logout(input1): if current_user.is_authenticated: return html.A('Salir', href='/logout') else: return '' if __name__ == '__main__': ##servidor local #app.run_server(debug=True) ##servidor redlan port = int(os.environ.get('PORT', 5000)) debug = os.environ.get('PRODUCTION') is None app.run_server(debug=debug, host='192.168.43.137', port=port)
@app.callback(Output('doctor', 'children'), [Input('page-content', 'children')]) def doctor(input1): if current_user.is_authenticated: return html.A('Doctor', href='/doctor', className="hoverHeader") else: return '' @app.callback(Output('login', 'children'), [Input('page-content', 'children')]) def user_logout(input1): if not current_user.is_authenticated: return html.A('Login', href='/login', className="hoverHeader") else: return '' @app.callback(Output('sign-up', 'children'), [Input('page-content', 'children')]) def user_logout(input1): if not current_user.is_authenticated: return html.A('Sign up', href='/sign-up', className="hoverHeader") else: return '' if __name__ == '__main__': app.run_server(debug=True)
return 'Login', '/login' # @app.callback( # Output('user-name', 'children'), # [Input('page-content', 'children')]) # def profile_link(content): # ''' # returns a navbar link to the user profile if the user is authenticated # ''' # if current_user.is_authenticated: # return html.Div(current_user.first) # else: # return '' # @app.callback( # [Output('user-action', 'children'), # Output('user-action','href')], # [Input('page-content', 'children')]) # def user_logout(input1): # ''' # returns a navbar link to /logout or /login, respectively, if the user is authenticated or not # ''' # if current_user.is_authenticated: # return 'Logout', '/logout' # else: # return 'Login', '/login' if __name__ == '__main__': app.run_server(host='0.0.0.0', port=8095)
html.Hr(), html.A(href='/dash/', children='Back to the Table of Contents') ]) return content app.routes = [ { 'pathname': chapter_object['url'], 'state': {'toc.value': chapter_id} } for chapter_id, chapter_object in six.iteritems(chapters) ] app.css.append_css({ 'external_url': ( 'https://cdn.rawgit.com/plotly/dash-app-stylesheets/f6fed04e3f23c2ac5b4ea88819c2c14c07e88442/dash-docs-base.css', 'https://cdn.rawgit.com/plotly/dash-app-stylesheets/30b641e2e89753b13e6557b9d65649f13ea7c64c/dash-docs-custom.css', 'https://fonts.googleapis.com/css?family=Dosis' ) }) if 'DYNO' in os.environ: app.scripts.config.serve_locally = False app.scripts.append_script({ 'external_url': 'https://cdn.rawgit.com/chriddyp/ca0d8f02a1659981a0ea7f013a378bbd/raw/e79f3f789517deec58f41251f7dbb6bee72c44ab/plotly_ga.js' }) else: app.scripts.config.serve_locally = True if __name__ == '__main__': app.run_server(debug=True, threaded=True, port=8050)
@app.callback( Output('user-name', 'children'), [Input('page-content', 'children')]) def cur_user(input1): if current_user.is_authenticated: return html.Div('Usuario Actual: ' + current_user.username) # 'User authenticated' return username in get_id() else: return '' @app.callback( Output('logout', 'children'), [Input('page-content', 'children')]) def user_logout(input1): if current_user.is_authenticated: return html.A('Salir', href='/logout') else: return '' if __name__ == '__main__': ##servidor local #app.run_server(host='0.0.0.0') #app.run_server(debug=True) ##servidor redlan port = int(os.environ.get('PORT', 5000)) debug = os.environ.get('PRODUCTION') is None #app.run_server(debug=debug, host='192.168.43.137', port=port) app.run_server(debug=debug, host='192.168.1.33', port=port)
'height': '60px', 'width': '100px' })) ] + [ html.Td( html.Div(html.P(['© 2020 Discourse Processing Lab.']))) ])) ], className='mainfooter'), else: footer = html.Div([]) return footer @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/apps/textanalyzer': return get_page_divs(textanalyzer.layout()) elif pathname == '/apps/topicmodel': return get_page_divs(topicmodel.layout()) elif pathname == '/apps/topsources': return get_page_divs(topsources.layout()) elif pathname == '/apps/topsourcetrends': return get_page_divs(topsourcetrends.layout()) else: return get_page_divs(home_page, enable_footer=False) if __name__ == '__main__': app.run_server(host='0.0.0.0', port=8050, debug=True)
actives.append(False) if type(x.path) == list: if pathname in x.path: actives.append(True) else: actives.append(False) return actives @app.callback(Output("page-content", "children"), [Input("url", "pathname")]) def render_page_content(pathname): for x in routes: if type(x.path) == str: if pathname == x.path: return x.content if type(x.path) == list: if pathname in x.path: return x.content 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=sets.APP_PORT, debug=sets.APP_DEBUG, threaded=sets.APP_THREADED)
'width': '90%', 'textAlign': 'center' }, { 'if': { 'column_id': '发文量' }, 'width': '10%', 'textAlign': 'center' }, ], tooltip_data=[{ column: { 'value': str(value), 'type': 'markdown' } for column, value in row.items() } for row in df_ins_sub.to_dict('rows')], tooltip_duration=None) return table, else: return [] ############################################################################### # run app ############################################################################### if __name__ == '__main__': app.run_server(debug=True, port=8432)
# create page layout app.layout = html.Div(id='if-web-auth-frame') @app.callback(Output('if-web-auth-frame', 'children'), [Input('if-web-auth-frame', 'id')]) def dynamic_layout(_): token = flask.request.cookies.get('if-web-dashboard-token') if not token: # If there's no cookie we need to login. return login.get_layout() if not current_user.set_token(token): # If there's no cache file for logged in user return login.get_layout() if current_user.get_user_data() is None: # If there's no cookie we need to login. return login.get_layout() return page.get_layout() # run the server if __name__ == '__main__': # debug mode True/False # host ip ex: 127.0.0.1 (local), 0.0.0.0 (public) app.run_server(debug=config.dev_env, host=config.host_ip)
url_bar_navbar_content = html.Div([ dcc.Location(id='url', refresh=False), html.Div(children=[navbar, html.Div(id='page-content')]) ]) # When developing a multi-page app, this part will ensure that all callbacks are validated before serving the app # See: https://dash.plot.ly/urls def serve_layout(): if flask.has_request_context(): return url_bar_navbar_content return html.Div([ url_bar_navbar_content, home.layout, ]) app.layout = serve_layout @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def routes(pathname): if pathname == '/': return home.layout else: return '404' if __name__ == '__main__': app.run_server(host='0.0.0.0', port=8055, debug=True, threaded=True)
@app.callback(Output('user-name', 'children'), [Input('page-content', 'children')]) def cur_user(input1): if current_user.is_authenticated: return html.Div('Current user: '******'User authenticated' return username in get_id() else: return '' @app.callback(Output('logout', 'children'), [Input('page-content', 'children')]) def user_logout(input1): if current_user.is_authenticated: return html.A('Logout', href='/logout') else: return '' @app.callback(Output('add-user', 'children'), [Input('page-content', 'children')]) def adding_user(input1): if current_user.is_authenticated: return html.A('Add User', href='/add-user') else: return '' if __name__ == '__main__': app.run_server(host='localhost', debug=True)
# index page import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from server import app, server from views import main_view app.layout = html.Div([ html.Div([ html.Div(html.Div(id='page-content', className='content'), ), ]), dcc.Location(id='url', refresh=False), ]) @app.callback(Output('page-content', 'children'), [ Input('url', 'pathname'), ]) def display_page(pathname): if pathname == '/': return main_view.layout else: return main_view.layout if __name__ == '__main__': app.run_server(host='0.0.0.0', debug=False)
for n in range(2, 4): app.callback(Output(u"kccq-modal-answer-prior-{}".format(n), 'is_open'), [ Input("kccq-modal-answer-prior-button-open-{}".format(n), "n_clicks"), Input("kccq-modal-answer-prior-button-submit-{}".format(n), "n_clicks") ], [State("kccq-modal-answer-prior-{}".format(n), 'is_open')])(open_modal) # prior video review modal def open_modal(n1, n2, is_open): if n1 or n2: return not is_open else: return is_open for n in range(2, 4): app.callback( Output(u"modal-selfrecording-review-prior-{}".format(n), 'is_open'), [ Input("video-modal-review-prior-button-open-{}".format(n), "n_clicks"), Input("video-modal-review-prior-button-submit-{}".format(n), "n_clicks") ], [State("modal-selfrecording-review-prior-{}".format(n), 'is_open') ])(open_modal) if __name__ == "__main__": app.run_server(host="127.0.0.1", debug=True, port=8051)
@app.callback(Output('user-name', 'children'), [Input('page-content', 'children')]) def profile_link(content): """ returns a navbar link to the user profile if the user is authenticated """ if current_user.is_authenticated: return html.Div(current_user.first) else: return '' @app.callback( [Output('user-action', 'children'), Output('user-action', 'href')], [Input('page-content', 'children')]) def user_logout(input1): """ returns a navbar link to /logout or /login, respectively, if the user is authenticated or not """ if current_user.is_authenticated: return 'Logout', '/logout' else: return 'Login', '/login' if __name__ == '__main__': app.run_server(host=config.server_ip, port=config.server_port, debug=config.debug)
values = (mv_numeric_options, mv_numeric_options, mv_categoric_options, mv_categoric_options, mv_categoric_options, "cum_mv", "mv") return values else: graph_df = transfers hover_data = transfers_hover_data values = (numerical_options, numerical_options, categorical_options, categorical_options, categorical_options, "mv", "fee") return values @app.callback(Output("graph", "figure"), inputs) def make_figure(x=None, y=None, color=None, facet_col=None, facet_row=None): fig = px.scatter(graph_df, x=x, y=y, color=color, hover_data=hover_data, facet_col=facet_col, facet_row=facet_row, trendline="ols", facet_col_wrap=4) if (not (facet_col is None) or not (facet_row is None)): fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[1])) return fig if __name__ == '__main__': app.run_server(debug=False)
@app.callback(Output('doctor', 'children'), [Input('page-content', 'children')]) def doctor(input1): if current_user.is_authenticated: return html.A('Doctor', href='/doctor', className="hoverHeader") else: return '' @app.callback(Output('login', 'children'), [Input('page-content', 'children')]) def user_logout(input1): if not current_user.is_authenticated: return html.A('Login', href='/login', className="hoverHeader") else: return '' @app.callback(Output('sign-up', 'children'), [Input('page-content', 'children')]) def user_logout(input1): if not current_user.is_authenticated: return html.A('Sign up', href='/sign-up', className="hoverHeader") else: return '' if __name__ == '__main__': app.run_server(debug=True, host='0.0.0.0', port=5070)
from server import app if __name__ == '__main__': print('Dash starting server...') app.run_server(host='127.0.0.1', port=8000, debug=True)
style={"width": "100%"}, ) ############################################################################## # main app layout app.layout = dbc.Container( [ dbc.Row([ navbar, links_storage_memory, links_storage_memory_debug, # best_perp_storage_memory ]), dbc.Row([ dbc.Col([control_buttons, links_view_layout], md=2), dbc.Col([cytoplot_layout], md=6), dbc.Col( [ right_layout_for_normal, # right_layout_for_chain, ], md=4), ]), # dbc.Row([dbc.Col([bottom_layout])]), ], fluid=True, ) if __name__ == "__main__": app.run_server(debug=True, threaded=True, host="0.0.0.0", processes=1)
elif level2_tabs == 'model_builder': return Model_Builder.SideBar_modelBuilder elif level2_tabs == 'pipelines': return [html.H4(f"Tab is {level2_tabs}")] else: return [html.H4(f"Tab is {level2_tabs}")] else: return [] if __name__ == "__main__": # TODO: Implement user_id correctly: # create a Redis entry with all `user_id`s that # joined the session and cleanup for each of them # TODO: Consider making this an executable # https://community.plot.ly/t/convert-dash-to-executable-file-exe/14222 try: app.run_server(debug=True, host='0.0.0.0') finally: cleanup(r) else: # Probably a deployment (we need it here because of Dash) # not having a layout defined in server.py server = app.server
from server import app from layouts.main import main_layout app.layout = main_layout from callbacks.main import * if __name__ == '__main__': app.run_server(host='127.0.0.1', port='8080', debug=True)
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from server import app, server from views import main_view app.layout = html.Div( [ html.Div([ html.Div( html.Div(id='page-content', className='content'), ), ]), dcc.Location(id='url', refresh=False), ] ) @app.callback( Output('page-content', 'children'), [Input('url', 'pathname'),]) def display_page(pathname): if pathname == '/': return main_view.layout else: return main_view.layout if __name__ == '__main__': app.run_server(host='127.0.0.1', debug=False)
html.Div(html.Img(src=app.get_asset_url('logo.png'), height="50%"), style={ "margin": "auto", "paddingTop": "20px", "height": "70%", "width": "100px" }) ], className="row header", style={ "backgroundColor": "#27303A", "marginBottom": "30px" }), html.Div(layout, id="full_content", className="row", style={ "marginBottom": "5px", "textAlign": "center", }), html.Link(href="https://fonts.googleapis.com/css?family=Open+Sans", rel="stylesheet"), html.Link(href="https://fonts.googleapis.com/css?family=Ubuntu", rel="stylesheet") ]) import callbacks if __name__ == "__main__": app.run_server(host='0.0.0.0', port=5001)
{%css%} <!-- Google Tag Manager Tag --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-N6T2RXG');</script> </head> <body> <!-- Google Tag Manager Tag --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N6T2RXG" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> {%app_entry%} <footer> {%config%} {%scripts%} {%renderer%} </footer> </body> </html>''' if __name__ == '__main__': app.run_server(port=8060, processes=4, threaded=False, debug=True, use_reloader=False, use_debugger=True, dev_tools_hot_reload=False, dev_tools_ui=True)
return registration.layout() if current_user.is_authenticated: if pathname == '/logout': logout_user() return login.layout() elif pathname == '/' or pathname == '/home': return home.layout() elif pathname == '/profile': return profile.layout() return html.Div(html.Strong(html.H1('Error 404! Page not found!')), style=dict(textAlign='center')) @app.callback([ Output('user-action', 'children'), Output('user-action', 'href'), Output('profile', 'children'), Output('navigation_panel', 'style') ], [Input('page-content', 'children')]) def user_logout(input): if current_user.is_authenticated: return 'Logout', '/logout', html.Div(current_user.username), {} else: return 'Sign In', '/login', '', dict(display='none') if __name__ == '__main__': app.run_server(host='0.0.0.0', port=8050, debug=DEBUG)
], state=[ State('opt-cluster-method', 'options'), State('opt-cluster-method', 'value') ]) def callback_figure_change(clc, xop, xval, yop, yval, zop, zval, options, value): """If figure 1 gets changed, query for figure 2.""" global cluster_algos global dataset_loader if value is None: return None key_sel = options[value]['label'] cluster_algos.get_class(key_sel)._data = dataset_loader.get_active() post_settings = cluster_algos._sliders_post.get(key_sel) return cluster_algos.get_class(key_sel).get_figure_2( style={'height': '100%'}, **post_settings) # CSS pens app.css.append_css( {'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'}) app.css.append_css( {"external_url": "https://codepen.io/chriddyp/pen/brPBPO.css"}) app.config['suppress_callback_exceptions'] = False if __name__ == '__main__': app.run_server(debug='False', port=8050, host='0.0.0.0')
app.layout = html.Div([ # empty Div to trigger javascript file for graph resizing html.Div(id="output-clientside"), # Header header.layout(), dcc.Tabs([ dcc.Tab(label='Similarité description produits/commentaires', value='Similarity', children=similarity.layout()), dcc.Tab( label= 'Distribution des attributs dans les descriptions & commentaires', value='Attributes', children=attributes.layout()), # dcc.Tab( # label='Markets worldwide', # value='Markets', # children=markets.layout() # ), # dcc.Tab( # label='Geography', # value='Geography', # children=imap.layout() # ) ]) ]) if __name__ == "__main__": app.run_server(debug=False, port=8051)
(nClicks, oldStyle) => { if (nClicks) { if (oldStyle.width === '300px') { return [ { 'width': 0, 'height': '100vh', 'overflowY': 'auto', 'transition': 'width 0.2s' }, 'antd-menu-unfold' ] } return [ { 'width': '300px', 'height': '100vh', 'transition': 'width 0.2s' }, 'antd-menu-fold' ] } return window.dash_clientside.no_update; } ''', [Output('side-menu', 'style'), Output('fold-side-menu-icon', 'icon')], Input('fold-side-menu', 'nClicks'), State('side-menu', 'style')) if __name__ == '__main__': app.run_server(debug=True, port=8051)
from load_page_dash import layout as layout_load from server import app from navbar import navbar as layout_navbar app.layout = layout_load if __name__ == '__main__': app.run_server(debug=True, dev_tools_ui=True) # 0.883 m3 to MT