import dash import dash_auth import appCredentials import flask app = flask.Flask(__name__) dash_app = dash.Dash(__name__, server=app) dash_app.config.update({ # 'routes_pathname_prefix': '/', # 'requests_pathname_prefix': 'ratings/', 'suppress_callback_exceptions': True }) auth = dash_auth.BasicAuth(dash_app, appCredentials.VALID_USERNAME_PASSWORD_PAIRS)
#import libraries import dash import dash_auth import sqlite3 #open connection with user database connection = sqlite3.connect("database/usernames.db") cur = connection.cursor() #retrieve usernames and passwords cur.execute('SELECT username, password FROM user') VALID_USERNAME_PASSWORD = cur.fetchall() #import a css stylesheet (provided through Dash documentation) external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] #initialize app with css and check for user login app = dash.Dash(__name__, external_stylesheets=external_stylesheets) server = app.server auth = dash_auth.BasicAuth(app, VALID_USERNAME_PASSWORD) app.config.suppress_callback_exceptions = True
loaded_model = model_from_json(loaded_model_json) # load weights into new model loaded_model.load_weights("model.h5") print("Loaded model from disk") # compile the model loaded_model.compile(optimizer = 'sgd', loss = 'mse', metrics = ['mape']) #============================================================================== user_password = [['username', 'password'], ['nrgds', '1234']] app = dash.Dash() auth = dash_auth.BasicAuth(app, user_password) server = app.server colors = { 'background': '#111111', 'text': '#808080' } hover_text = [] for index, row in df_new.iterrows(): hover_text.append(('Movie Name: {mvname}<br>'+ 'Reserved_Total: {rs:,.0f}<br>'+ 'Reserved_Wed_Afternoon: {rswa:,.0f}<br>'+
# pip install dash==0.17.8rc1 # pip install dash-auth==0.0.2 import dash import dash_auth import dash_html_components as html import dash_core_components as dcc import plotly app = dash.Dash('auth') auth = dash_auth.BasicAuth(app, (( 'hello', 'world', ), )) app.layout = html.Div([ html.H1('Welcome to the app'), html.H3('You are successfully authorized'), dcc.Dropdown(id='dropdown', options=[{ 'label': i, 'value': i } for i in ['A', 'B']], value='A'), dcc.Graph(id='graph') ], className="container") @app.callback(dash.dependencies.Output('graph', 'figure'), [dash.dependencies.Input('dropdown', 'value')])
# -*- coding: utf-8 -*- """ Created on Wed Sep 5 18:00:42 2018 @author: arnaud """ import os import dash import dash_auth from models import mod_orders # Pour avoir les mois des dates en français import locale locale.setlocale(2, '') #df_orders = mod_orders.OrdersClass().df_orders # Déclaration de l'application app = dash.Dash('auth') auth = dash_auth.BasicAuth(app, [[os.environ['appuser'], os.environ['apppass']]]) server = app.server # Pour éviter les warnings dus au multipage layout app.config.suppress_callback_exceptions = True app.css.append_css( {'external_url': 'https://codepen.io/chriddyp/pen/bWLwgP.css'})
process_df_name = "_cluster_result.parquet.gzip" periods = 30 result_col_name = "cluster" metrics_dir = "data/metrics/" metrics_plckle_name = "_metrics_cluster_result.pickle" not_cluster_list = ["0", "1"] # ignore anomalies and business rules path = "/" external_stylesheets = [dbc.themes.BOOTSTRAP] dash_app = dash.Dash(__name__, external_stylesheets=external_stylesheets, requests_pathname_prefix=path) # add login auth = dash_auth.BasicAuth( dash_app, {USERNAME: PASSWORD}, ) dash_app.layout = html.Div(children=[ # load dataset html.H1(children='Clustering Dashboard', style={ 'color': 'gray', 'text-align': 'center' }), html.Br(), html.Div( dbc.Row([ dbc.Col( html.H5(children='Select a date',
def setup_dash(config): """Set up dashboard server.""" dash_config = config["dash"] external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) if "creds" in dash_config: creds = dash_config["creds"] if "user" in creds and "password" in creds: if creds["user"] != "" and creds["password"] != "": dash_auth.BasicAuth(app, {creds["user"]: creds["password"]}) app.layout = html.Div([ html.Div(id="watchlist-table", children=get_watchlist_table(config)), html.Div(children=[html.Br()]), html.Div(children="Symbol:"), dcc.Input(id="symbol", value="", type="text"), html.Div(children=[html.Br()]), html.H1(id="heading", children="", style={"textAlign": "center"}), html.Div(id="description-blob", style={"textAlign": "center"}), html.Div(id="fundamentals-table"), html.Div(children=[html.Br(), html.Br()]), html.Div(children=[ dcc.RadioItems(id="day-fib-radio", options=[{ "label": "Fibonacci Off", "value": False }, { "label": "Fibonacci On", "value": True }], value=None, labelStyle={"display": "inline-block"}), dcc.RadioItems(id="day-fib-direction-radio", options=[{ "label": "Extension", "value": "Up" }, { "label": "Retracement", "value": "Down" }], value=None, labelStyle={"display": "inline-block"}), " High: ", dcc.Input(id="day-fib-high-input", value="", type="float"), " Low: ", dcc.Input(id="day-fib-low-input", value="", type="float") ]), dcc.Graph(id="day-graph"), html.Div(children=[ dcc.RadioItems(id="week-fib-radio", options=[{ "label": "Fibonacci Off", "value": False }, { "label": "Fibonacci On", "value": True }], value=None, labelStyle={"display": "inline-block"}), dcc.RadioItems(id="week-fib-direction-radio", options=[{ "label": "Extension", "value": "Up" }, { "label": "Retracement", "value": "Down" }], value=None, labelStyle={"display": "inline-block"}), " High: ", dcc.Input(id="week-fib-high-input", value="", type="float"), " Low: ", dcc.Input(id="week-fib-low-input", value="", type="float") ]), dcc.Graph(id="week-graph"), html.Div(children=[ dcc.RadioItems(id="year-ema-radio", options=[{ "label": "EMAs Off", "value": False }, { "label": "EMAs On", "value": True }], value=None, labelStyle={"display": "inline-block"}) ]), html.Div(children=[ dcc.RadioItems(id="year-fib-radio", options=[{ "label": "Fibonacci Off", "value": False }, { "label": "Fibonacci On", "value": True }], value=None, labelStyle={"display": "inline-block"}), dcc.RadioItems(id="year-fib-direction-radio", options=[{ "label": "Extension", "value": "Up" }, { "label": "Retracement", "value": "Down" }], value=None, labelStyle={"display": "inline-block"}), " High: ", dcc.Input(id="year-fib-high-input", value="", type="float"), " Low: ", dcc.Input(id="year-fib-low-input", value="", type="float") ]), dcc.Graph(id="year-graphs") ]) return app
import dash import dash_auth import dash_bootstrap_components as dbc from foiv_helper.callbacks import register_callbacks from foiv_helper.layouts import serve_layout from foiv_helper.load_cfg import Check_username_password app = dash.Dash(__name__, title='Полномочия и роли пользователей', external_stylesheets=[dbc.themes.BOOTSTRAP]) server = app.server auth = dash_auth.BasicAuth(app, Check_username_password) app.layout = serve_layout register_callbacks(app) if __name__ == '__main__': app.run_server()
import reporter import dash_auth import keys reporter.ADMIN = True app = reporter.app dash_auth.BasicAuth(app, keys.USERNAME_PASSWORD) server = app.server
import dash_bootstrap_components as dbc import dash_table import dash_auth from dash.dependencies import Input, Output, State import plotly.graph_objs as go import warnings import pandas as pd from datetime import datetime, timedelta import os filename = 'data/XGB_Model_Predictions.csv' lastmt = os.stat(filename).st_mtime username_password_pairs = [['username', 'password']] app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) auth = dash_auth.BasicAuth(app, username_password_pairs) server = app.server app.layout = html.Div([ dbc.Tabs([ dbc.Tab(html.Div( [ dash_table.DataTable( id='raw_data', data=[], style_table={ 'height': '200px', 'overflowY': 'scroll', }, style_cell={
import dash import dash_auth from helpers.get_logins import * # read in names-passwords # passwords should be saved in the same path as app.py password_file_name = 'logins' login_list = return_login_info(password_file_name) # create the app app = dash.Dash() # add the app authentication auth = dash_auth.BasicAuth(app, login_list) # define the app's server server = app.server # for dev only app.config.suppress_callback_exceptions = True # add Boostrap CSS #app.css.append_css({'external_url':'https://codepen.io/chriddyp/pen/bWLwgP.css'}). # plotly official css app.css.append_css({ 'external_url': 'https://codepen.io/jginsberg3/pen/zJPVBq.css' }) # jg fork of the plotly official css
import dash import dash_core_components as dcc import dash_html_components as html import dash_auth from dash.dependencies import Input, Output import plotly.express as px #(need to pip install plotly==4.4.1) df = pd.read_csv("park.csv") # you need to include __name__ in your Dash constructor if # you plan to use a custom CSS or JavaScript in your Dash apps app = dash.Dash(__name__) server = app.server ## auth = dash_auth.BasicAuth(app, {'admin': 'admin', 'admin2': 'admin2'}) #--------------------------------------------------------------- app.layout = html.Div([ html.Div([ html.Label(['NYC Calls for Animal Rescue']), dcc.Dropdown(id='my_dropdown', options=[{ 'label': 'Action Taken by Ranger', 'value': 'Final Ranger Action' }, { 'label': 'Age', 'value': 'Age' }, { 'label': 'Animal Health', 'value': 'Animal Condition' }, {
def h(x): return np.sin(x) fig1 = go.Figure(go.Scatter(x=x, y=f(x))) fig2 = go.Figure(go.Scatter(x=x, y=h(x))) external_stylesheets = [ 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css' ] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) server = app.server auth = dash_auth.BasicAuth(app, [('admin', 'secret')]) row0 = html.Div([html.Div([html.H1('Заголовок')], className='col-sm')], className='row') row1 = html.Div([ html.Div([dcc.Graph(figure=fig1)], className='col-sm'), html.Div([dcc.Graph(figure=fig2)], className='col-sm') ], className='row') row2 = html.Div([ html.Div([html.P('f(x) = x<sup>2</sup>')], className='col-sm'), html.Div([html.P('h(x) = sin(x)')], className='col-sm') ], className='row')
port = database.Portfolio() port.update_portfolio() df = port.portfolio app = dash.Dash(title="Portfolio Analyser") try: if os.path.isfile("data/basic_auth.txt"): print("INFO: Found auth credentials in 'basic_auth.txt', resuming with basic-auth ENABLED") f = open("data/basic_auth.txt", "r") auth_cred_pair_raw = f.read().splitlines() auth_cred_pair = {auth_cred_pair_raw[0]: auth_cred_pair_raw[1]} f.close() auth = dash_auth.BasicAuth(app, auth_cred_pair) else: print("WARNING: Could not find or load 'basic_auth.txt' file, resuming with basic-auth DISABLED!") except Exception as e: print("WARNING: Could not find or load 'basic_auth.txt' file, resuming with basic-auth DISABLED!") print(e) allocation = go.Figure() holdings_perf = go.Figure() app.layout = html.Div(children=[ html.H1(children="Portfolio Analyser", style={"textAlign": "center", "font-size": "8rem", "font-weight": "780"}), html.Div([
], ind_elements=[side_nav, download_button, methodology, paginator], footer_image="/static/images/UNICEF-MOH-bottom-resized.jpg", title="Continuity of Essential Health Services", sub_title= "Overview of country, district and health facility-level health services in Uganda", footer_text=dcc.Link( children="Dalberg Data Insights - Contact Us", href="mailto:[email protected]", ), ) app = ds.app app.title = "CEHS Uganda" auth = dash_auth.BasicAuth(app, credentials) ################# # CALLBACKS # ################# callback_ids = { outlier_policy_dropdown_group.dropdown_ids[-1]: "value", indicator_dropdown_group.dropdown_ids[-1]: "value", reference_date.dropdown_ids[0]: "value", reference_date.dropdown_ids[-1]: "value", target_date.dropdown_ids[0]: "value", target_date.dropdown_ids[-1]: "value", district_control_group.dropdown_ids[-1]: "value", indicator_dropdown_group.dropdown_ids[0]: "value", }
import dash_table import pandas as pd import phonenumbers from dash.dependencies import Input, Output, State from dotenv import load_dotenv from jinja2 import Template from twilio_client import TwilioClient # Load .env variable load_dotenv(join(dirname(__file__), '.env')) COL_NAMES = ['first_name', 'last_name', 'phone_number'] app = dash.Dash('Bulk SMS', external_stylesheets=[dbc.themes.COSMO]) auth = dash_auth.BasicAuth(app, {getenv("USERNAME"): getenv("PASSWORD")}) server = app.server twilio_client = TwilioClient(server) sidebar = html.Div( style={ "position": "fixed", "top": 0, "left": 0, "bottom": 0, "width": "20rem", "padding": "2rem 1rem", "background-color": "#f8f9fa", }, children=[ html.H2("Bulk SMS", className="display-4"),
url_base_pathname='/basf/', assets_url_path='/basf') server = app.server app.config["suppress_callback_exceptions"] = True ############################# # Database connect ############################# with open('./secrets/db_info.json') as json_file: db_login = json.load(json_file) # app_login VALID_USR_PASS = {db_login["dash_name"]: db_login["dash_pass"]} auth = dash_auth.BasicAuth( app, VALID_USR_PASS, ) # database login client = MongoClient(db_login['host'], username=db_login['username'], password=db_login['password'], authSource=db_login['database'], authMechanism='SCRAM-SHA-1') mongo_coll = client[db_login['database']][db_login['collection']] mongo_coll_path = client[db_login['database']][db_login['collection2']] mongo_coll_mat = client[db_login['database']][db_login['collection3']] mongo_coll_task = client[db_login['database']][db_login['collection4']] show_fields = [ 'battid', 'average_voltage', 'working_ion', 'capacity_grav', 'energy_grav', 'formula_charge', 'formula_discharge', 'id_charge', 'id_discharge',
def plot_points(dataframe_all_points): external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) auth = dash_auth.BasicAuth(app, VALID_USERNAME_PASSWORD_PAIRS) data_yes_no_Asp = [] for criterion in ["yes", "no"]: data_filling_criterion = dataframe_all_points[dataframe_all_points["Asp.Fm"] == criterion] data_dictionary = dict( x=data_filling_criterion["Easting"], y=data_filling_criterion["Northing"], text=data_filling_criterion["Author"] + " " + "(" + data_filling_criterion["Year"].astype(str) + ")", mode='markers', name="Data point includes Asp.Fm" if criterion == "yes" else "Data point excludes Asp.Fm", opacity=0.7, customdata=data_filling_criterion.index, marker={ 'size': 15, 'line': {'width': 0.5, 'color': 'white'} }, ) data_yes_no_Asp.append(data_dictionary) bg_map = go.Figure() # or any Plotly Express function #bg_map.add_trace( # go.Scatter(x=[0, 0.5, 1, 2, 2.2], y=[1.23, 2.5, 0.42, 3, 1]) #) bg_map.add_layout_image( dict( source="/static/Dash_background_map_noFM.jpg", xref="x", yref="y", x=484914.000, y=8687643.227, sizex=71309.39099999995, sizey=100851.85400000028, sizing="stretch", opacity=0.7, layer="below" ) ) aspelintoppen = gpd.read_file("Shapes for interactive map/Aspelintoppen.shp") x_cords = [] y_cords = [] for geometry in aspelintoppen.geometry: x_cords += geometry.exterior.xy[0].tolist() +[None] y_cords += geometry.exterior.xy[1].tolist() +[None] bg_map.add_trace(go.Scatter( x=x_cords, y=y_cords, fill="toself", fillcolor="rgb(252, 217, 88)", opacity=0.75, line=dict(color="rgba(0, 0, 0, 0)"), name="Aspelintoppen Formation" )) helisurvey = gpd.read_file("Shapes for interactive map/own_localities.shp") x_cords = [] y_cords = [] for geometry in helisurvey.geometry: x_cords += geometry.exterior.xy[0].tolist() +[None] y_cords += geometry.exterior.xy[1].tolist() +[None] bg_map.add_trace(go.Scatter( x=x_cords, y=y_cords, fill="toself", fillcolor="rgb(227, 113, 144)", opacity=0.75, line=dict(color="rgba(227, 113, 144, 100)"), name="Aerial images (2020)" )) for data_dictionary in data_yes_no_Asp: # Plots data from data_dictionary on map bg_map.add_trace(data_dictionary) bg_map.layout["yaxis"] = { "scaleanchor": "x", "scaleratio": 1 } app.layout = html.Div(children=[ html.H1(children="Upper Van Mijenfjorden Group interactive map"), html.H4(children="Created as part of master thesis project by Anna Bøgh Mannerfelt"), html.Div(children=get_time_of_latest_commit()), html.Div(children='''This interactive map was created by the author, Anna Bøgh (MSc student at UiB and UNIS).'''), html.Div(children='''All previously collected data was compiled and extracted from articles, master theses and PhD theses by the author.'''), html.Div(children='''Data with reference "Bøgh..." was collected by the author.'''), dcc.Graph(figure=bg_map, id='Aspelintoppen Fm data', style={"width": "50%", "height": "1000px", "float": "left"}), html.Div(id="hidden_div_for_redirect_callback"), html.Div([ dcc.Markdown(""" **Selection Data** To view and download data, choose the lasso or rectangle tool in the graph's menu bar and then mark one or several points in the map. To select more points without letting go of the first selection, hold down Shift button. To view log data and reference, **click on a row**. To view log image in greater detail and to download, click on the image. The image will load in another tab in your browser. (Empty Index name fields indicate no available log image. Instead, please see article reference to learn more.) """), dash_table.DataTable( id='selected_data', columns=[{"name": i, "id": i} for i in dataframe_all_points.columns], data=dataframe_all_points.to_dict("records"), hidden_columns=["Reference"], css=[{"selector": ".show-hide", "rule": "display: none"}] ), ], style={"width": "50%", "float": "right"} ), html.P(children="Reference: Select data in table above", id="reference_paragraph"), html.A(id="reference_link", target="_blank"), html.A(children=html.Img(id="log_image", style={"height": "600px", "float": "right", "max-width": "40%", "object-fit": "scale-down"}), target="_blank", id="image_link"), html.Div([ html.A(rel="license", href='http://creativecommons.org/licenses/by-nc-sa/4.0/', children=[ html.Img(alt='Creative Commons License', style={'border-width':'0'}, src="/static/88x31.png") ]), html.Br(), html.P("This work is licensed under a ", style={"display":"inline"}), html.A(rel="license", href='http://creativecommons.org/licenses/by-nc-sa/4.0/', children="Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License") ], style={"bottom": "0%", "position":"fixed"}) ]) @app.callback( Output('selected_data', 'data'), [Input('Aspelintoppen Fm data', 'selectedData')]) def display_selected_data(selectedData): selected_data = json.dumps(selectedData, indent=2) # points = selected_data["points"] if selectedData is None: return pd.DataFrame(columns=dataframe_all_points.columns).to_dict('records') # To do: change point index to something we know what is! indices = [point["customdata"] for point in selectedData["points"]] dataframe_all_points_copy = dataframe_all_points.copy() dataframe_all_points_copy[["Easting", "Northing"]] = dataframe_all_points_copy[["Easting", "Northing"]].astype(int) output = dataframe_all_points_copy.iloc[indices].to_dict('records') return output @app.callback(Output("selected_data", "selected_cells"), [Input('Aspelintoppen Fm data', 'selectedData')]) def reset_datatable_selection(selected_data): return [] @app.callback([Output("log_image", "src"), Output("image_link", "href"), Output("reference_paragraph", "children"), Output("reference_link", "children"), Output("reference_link", "href")], [Input("selected_data", "selected_cells"), Input('selected_data', 'data')] # When this is run two outputs are created: log image and image link ) def open_image_on_click(selected_cells, selectedData): results = { "log_image": None, "image_link": None, "reference_paragraph": "Reference: Select data in table above", "reference_link_text": None, "reference_link_link": None } #print(selected_cells) #if selected_cells is None: # return list(results.values()) try: column_id = selected_cells[0]["column_id"] except IndexError: return list(results.values()) row = selected_cells[0]["row"] selected_row = selectedData[row] reference = selected_row["Reference"] index_name = selected_row["Index name"] if reference is None or reference.strip() == "": results["reference_paragraph"] = "Reference: Reference not available, contact author for further details." else: results["reference_paragraph"] = "Reference: " results["reference_link_text"] = reference results["reference_link_link"] = reference if isinstance(index_name, str) and (index_name is not None and index_name.strip() != ""): link = "/static/Logs/{}.jpg".format(index_name) results["log_image"] = link results["image_link"] = link else: results["reference_paragraph"] = results["reference_paragraph"].replace("Reference: ", "Reference: Image not available. ") return list(results.values()) app.run_server(debug=True, port=1337, host="0.0.0.0")
app.css.append_css({'external_url': 'https://cdn.rawgit.com/plotly/dash-app-stylesheets/2d266c578d2a6e8850ebce48fdb52759b2aef506/stylesheet-oil-and-gas.css'}) # noqa: E501 if 'DYNO' in os.environ: app.scripts.append_script({ 'external_url': 'https://cdn.rawgit.com/chriddyp/ca0d8f02a1659981a0ea7f013a378bbd/raw/e79f3f789517deec58f41251f7dbb6bee72c44ab/plotly_ga.js' # noqa: E501 }) app.config['suppress_callback_exceptions']=True server = app.server server.secret_key = os.environ.get('secret_key', 'secret') auth = dash_auth.BasicAuth( app, (('Retailaudit','Distributionkpis',),('gfkinternal','gfkoneposdb',),('aajaya','gfkoneposdb37',),('APMEGM','conrad',),('APMEREGION','Distributionkpis',),('pasikka','gfkoneposdb38',),) ) app.layout = html.Div([ dcc.Location(id='url',refresh=True), html.Div(id='page-content'), html.Div(id='shelldbcontent'), ],style={'font-family': 'Calibri Light'},className='ten columns offset-by-one') # myauthenticateduser = auth._username # shelldb = shelldashboard.layout # shellhtu = howtouse.layout # shellnotes = notes.layout @app.callback(Output('page-content', 'children'),
# Experimental visualization of totalnum data using the output of totalnum_builddb. Uses dash. # Now supports deployment, multiple sessions, and gunicorn! # To run with gunicorn: GUNICORN_CMD_ARGS="--bind=0.0.0.0" gunicorn 'totalnum_dashboard_new:initApp("/path/to/database")' # by Jeff Klann, PHD 9-2018 instruction = """# How to use 1. Optionally choose a site from the dropdown 2. The options in the checkboxes start at the top level of the ontology. To navigate down the tree, check one box, click the button, and its children are displayed. 3. To display graphs, check boxes as desired. Temporal totalnum graphs will appear below. """ app = dash.Dash() # App Auth # Set username and password in local install, instead of hello world auth = dash_auth.BasicAuth(app, [['hello', 'world']]) # App Layout app.layout = html.Div([ dcc.Markdown(instruction), dcc.Dropdown(id='site', options=[]), html.Table([ html.Tr([ html.Td( html.Div([ dcc.Checklist(id='items', options=[{ 'label': 'No options', 'value': 'none' }], values=[],
# load data df_dashboard, latest_date, is_data_insufficient, days_req_for_warnings = get_dashboard_data( ) min_revenue_sum = df_dashboard['min_revenue'].sum() potential_revenue_sum = df_dashboard['potential_revenue'].sum() max_approved_revenue_sum = df_dashboard['max_revenue'].sum() # figures child_table = make_table(df_dashboard) revenue_chart = make_revenue_chart(df_dashboard) summary_table = make_attendance_table(df_dashboard) # dash app app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) app.title = 'Dashboard - Pie for Providers' auth = dash_auth.BasicAuth(app, {username: password}) server = app.server # navbar navbar = dbc.Navbar( dbc.Container( [ # Use row and col to control vertical alignment of logo / brand dbc.Row( [ dbc.Col(html.Img(src='/assets/pie_logo.png', height='50px')), ], align='center', no_gutters=True, )
assets = os.path.dirname(os.path.abspath(__file__)) + "/data/assets" app = dash.Dash("bifrost_dashboard", assets_folder=assets, external_stylesheets=external_stylesheets, external_scripts=external_scripts) app.title = "bifrost" app.config["suppress_callback_exceptions"] = True cache = Cache(app.server, config={ 'CACHE_TYPE': 'filesystem', 'CACHE_DIR': config["cache_location"] }) cache_timeout = 60 if config.get("pass_protected"): dash_auth.BasicAuth(app, config.USERNAME_PASSWORD) # Temp css to make it look nice # Lato font def samples_list(active, collection_name=None): links = [{ "icon": "fa-list", "href": "" }, { "icon": "fa-money-check", "href": "sample-report" }, { "icon": "fa-chart-pie", "href": "aggregate"
users_collection = db["users"] VALID_CREDENTIALS = [] def update_valid_credentials(): new_credentials = [[user["username"], user["key"]] for user in users_collection.find({}, {'_id': False})] for credentials in new_credentials: if credentials not in VALID_CREDENTIALS: VALID_CREDENTIALS.append(credentials) update_valid_credentials() app = dash.Dash(__name__, external_stylesheets=external_stylesheets) auth = dash_auth.BasicAuth(app, VALID_CREDENTIALS) def fetch_original_alerts(): timestamps = defaultdict(list) start = datetime.datetime.today().date() end = start + datetime.timedelta(days=1) delta = int((end - start).total_seconds() / 60) start_str = datetime.datetime.strftime(start, "%Y-%m-%d %H:%M:%S") end_str = datetime.datetime.strftime(end, "%Y-%m-%d %H:%M:%S") response = requests.post("http://localhost:8080/login", json={ "username": os.environ["ADMIN_USERNAME"], "password": os.environ["ADMIN_PASSWORD"]
import os import dash_auth import bifrost_dashboard.reporter import yaml config = yaml.safe_load(open(os.environ["BIFROST_DASH_CONFIG"])) bifrost_dashboard.reporter.ADMIN = True app = bifrost_dashboard.reporter.app dash_auth.BasicAuth( app, config['USERNAME_PASSWORD'] ) server = app.server
import dash import dash_auth import dash_html_components as html # ➊ 実際に用いる場合、ユーザ名とパスワードはソースコードに載せず、 # 別ファイルもしくはデータベースに保存する。 pass_pair = {"plotly": "dash", "test": "test1"} external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) # ➋ ユーザ名、パスワードを設定する。 auth = dash_auth.BasicAuth(app, pass_pair) app.layout = html.H1("Plotly Dash Bookへようこそ!", style={"textAlign": "center"}) if __name__ == "__main__": app.run_server(debug=True)
import pandas as pd import numpy as np import plotly.graph_objects as go from plotly.subplots import make_subplots import dash # (version 1.12.0) pip install dash import dash_core_components as dcc import dash_html_components as html import dash_auth #pip install dash-auth from dash.dependencies import Input, Output app = dash.Dash(__name__) auth = dash_auth.BasicAuth(app, {'resolve': 'resolve2020'}) # ------------------------------------------------------------------------------ # Import and clean data (importing csv into pandas) users = pd.read_csv('../Users.csv') events = pd.read_csv('../Events.csv') users['Event_Name'] = users['Event_Name'].replace( 'install', 'Instalacion').replace('FIRST_ORDER_PLACED_CONFIRMED_BACK', 'Primera_orden') users_dummie = pd.get_dummies(users, columns=['Event_Name'], drop_first=True) users2 = users[['Hour', 'Event_Name', 'clientID']].groupby(['Hour', 'Event_Name']).count() users2.reset_index(inplace=True) users2.sort_values(['Event_Name'], inplace=True) users['fecha'] = [x[:10] for x in users.Date] users3 = users[['fecha', 'Event_Name',
con=db_pd_Connection) db_pd_Connection.close() User_List = [] for i in db_User_List.index: User_List.append([db_User_List.Username[i], db_User_List.Password[i]]) del db_User_List # Dash app = dash.Dash() # Dash auth auth = dash_auth.BasicAuth(app, User_List) # Needed with taps app.config['suppress_callback_exceptions'] = True # ================================================================================ Functions ================================================================================ # ================================================================================ Functions ================================================================================ # ================================================================================ Functions ================================================================================ # ======================================== Server Shutdown ======================================== def Server_Shutdown(): func = request.environ.get('werkzeug.server.shutdown') if func is None: raise RuntimeError('Not running with the Werkzeug Server') func()
############################# # Dash Layout ############################# app.title = "Kelowna Culture Analysis" @server.route('/favicon.ico') def favicon(): return flask.send_from_directory(os.path.join(server.root_path, 'static'), 'favicon.ico') # user login authentication user_login_keys = get_user_login_keys() auth = dash_auth.BasicAuth(app, user_login_keys) app.layout = html.Div([ html.Img(src='assets/city_of_kelowna_logo.png', height='60vh', width='280vw', style={ 'display': 'inline-block', 'padding-bottom': 8 }), dcc.Tabs(id='tabs', children=[ first_tab.get_tab_layout(), second_tab.get_tab_layout(), third_tab.get_tab_layout(), fourth_tab.get_tab_layout()
df_latest_month # initially show the month leader .loc[df_latest_month['Gross sales'].idxmax()]['Consultant']) fig4 = (df_in_date[df_in_date['Consultant'] == month_leader].set_index( 'Month_label').iplot(keys=cols_to_graph_4, title=f'Consultant History - {month_leader}', asFigure=True)) gr4_bar = dcc.Graph(id='gr4', figure=fig4, style={'height': '87vh'}) # Logo demo_logo = 'DemoLogo.JPG' encoded_logo = base64.b64encode(open(demo_logo, 'rb').read()) # Dashboard layout app = dash.Dash() auth = dash_auth.BasicAuth(app, USERNAME_PASSWORD_PAIRS) app.layout = html.Div([ html.H1('Dashboard Demo', style={ 'background': '#0f3d8b', 'color': '#ffffff', 'borderRadius': '10', 'paddingLeft': '10', 'fontFamily': 'Georgia' }), html.H3('Consultant performance over time'), html.Div([ html.Div([ dcc.RadioItems( id='gr1_y_select',
from sqlalchemy.pool import NullPool from . import config import plotly.express as px import plotly.graph_objects as go from plotly.subplots import make_subplots import datetime import pmdarima as pm from pmdarima.model_selection import train_test_split import numpy as np from .queries import get_order_numbers, get_service_orders, get_bill_details, year_over_year, plot_yoy, get_budget, train_model_graph external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) auth = dash_auth.BasicAuth(app, config.auth_pair) app.config.suppress_callback_exceptions = True server = app.server app.layout = html.Div([ dcc.Tabs(id="tabs", value='tab-1', children=[ dcc.Tab(label='Aggregate Ticket Resolution', value='tab-1'), dcc.Tab(label='Billing Year Over Year', value='tab-2'), dcc.Tab(label='Billing Forecast', value='tab-3') ]), html.Div(id='tabs-content') ])