示例#1
0
def return_page1():
    E = html.Div([
        html.Div(
            dcc.LogoutButton(
                logout_url='/logout',
                className='button-logout',
                style={
                    'font-size': '0.8vw',
                    'vertical-align': 'middle',
                    'height': '2vw'
                },
            ),
            style={
                'display': 'inline-block',
                'height': '5vw'
            },
            id='logout_but2',
        ),
        # html.Div([
        #     dcc.Link(
        #         dbc.Button(size='lg', color="success", outline=True, children='Return', id='return_b',
        #                    disabled=False, style={
        #                 # 'marginTop':'165%',
        #                 'marginBottom': '5%', 'font-size': '0.7vw', }),
        #         id='link_b2', href='/logout'),
        # ], style={'textAlign': 'center', 'width': '100%', 'height': '100%'}),
    ])
    return E
示例#2
0
def navbar_dash():
    navbar_from_dashboard = dbc.Navbar(
        [
            html.A(
                dbc.Row([
                    dbc.Col(
                        html.Img(src="data:image/jpg;base64,{}".format(
                            encoded_client_logo.decode()),
                                 height="80px")),
                ], ),
                # Esto debe cambiar segun el cliente
                href="https://www.myclient.com/",
                target="_blank"),
            html.A(dbc.Row([
                dbc.Col(
                    html.Img(src="data:image/png;base64,{}".format(
                        encoded_company_LOGO.decode()),
                             height="80px")),
            ], ),
                   href="https://www.mycompany.com/",
                   target="_blank"),
            dbc.NavbarBrand("Dashboard"),
            html.Span(dcc.LogoutButton(logout_url='/logout'),
                      className="ml-auto")
        ],
        color="dark",
        dark=True,
    )
    return navbar_from_dashboard
示例#3
0
def render_content(data, nc, val):
    session_cookie = flask.request.cookies.get('custom-auth-session')

    if not session_cookie:
        # If there's no cookie we need to login.
        return go.Figure(
            data=[]
        ), login_form  #html.Div(html.H2("Charts will be displayed here after user's authentication."),
        #       style={'textAlign': 'center',
        #             'color': 'red'})

    else:

        logout_output = html.Div(children=[
            html.Div(html.H3('Hello {} !'.format(user_names[session_cookie])),
                     style={'display': 'inline-block'}),
            html.Div(dcc.LogoutButton(logout_url='/logout'),
                     style={'display': 'inline-block'})
        ],
                                 style={
                                     'color': 'green',
                                     'height': '50px'
                                 })
        if nc is not None:
            with open('result.csv', 'a+') as f:
                print(session_cookie)
                f.write('{},'.format(session_cookie) + '{} \n'.format(val))
            f.close()

        return go.Figure(data=beer_data, layout=beer_layout), logout_output
示例#4
0
def dynamic_layout(_):
    session_cookie = flask.request.cookies.get('custom-auth-session')

    if not session_cookie:
        return login_form

    return html.Div([dcc.LogoutButton(logout_url='/custom-auth/logout', )],
                    className='logout_button')
示例#5
0
def dynamic_layout(_):
    session_cookie = flask.request.cookies.get('custom-auth-session')
    if not session_cookie:
        # If there's no cookie we need to login.
        return login_form
    return html.Div([
        html.Div('Hello {}'.format(session_cookie)),
        dcc.LogoutButton(logout_url='/custom-auth/logout')
    ])
示例#6
0
        def on_location(location_path):
            if location_path is None:
                raise PreventUpdate

            if "logged-out" in location_path:
                return "Logged out"
            else:

                @flask.after_this_request
                def _insert_cookie(rep):
                    rep.set_cookie("logout-cookie", "logged-in")
                    return rep

                return dcc.LogoutButton(id="logout-btn", logout_url="/_logout")
def create_logout_button(label='Logout'):
    """
    Create a dcc.LogoutButton with the dash-deployment-server logout url set
    in the environment.

    :param label: Text of the logout button.
    :type label: str
    :return:
    """
    if not logout_url:
        raise Exception('DASH_LOGOUT_URL was not set in the environment.')

    return _dcc.LogoutButton(
        logout_url=logout_url,
        label=label,
    )
示例#8
0
def header(auth=None):
    return [
        dbc.NavbarSimple(
            [
                # Add other menu items here...

                # Logout button (only show if a user is logged in)
                dbc.NavItem(
                    dcc.LogoutButton(logout_url='/custom-auth/logout', className='btn btn-outline-danger'),
                    style={'display': 'none'} if not auth else {}
                ),
            ],
            brand=config.get('title', ''),
            brand_href='/',
            fluid=True,
            color='dark', dark=True
        ),
    ]
示例#9
0
    def create_logout_button(self,
                             id='logout-btn',
                             redirect_to='',
                             label='Logout',
                             **button_props):
        if self._logout_url:
            return dcc.LogoutButton(
                id=id,
                label=label,
                logout_url=self._logout_url,
                **button_props
            )

        location_id = '{}-{}'.format(id, 'loc')

        btn = html.Div([
            html.Button(label, id=id, **button_props),
            dcc.Location(id=location_id),
        ])

        # setup the callback only after the btn has been inserted in the layout
        @self.app.server.before_first_request
        def _log_out_callback():

            @self.app.callback(Output(location_id, 'href'),
                               [Input(id, 'n_clicks')])
            def _on_log_out(n_clicks):
                if not n_clicks:
                    return

                app_url = self._app_url[0] if \
                    isinstance(self._app_url, (list, tuple)) else self._app_url

                redirect = redirect_to or '{}?t={}'.format(
                    app_url,
                    int(time.time()))

                self.logout()

                return redirect

        return btn
示例#10
0
def serve_layout():
    session_cookie = flask.request.cookies.get("custom-auth-session")

    # landing login page
    if session_cookie not in user_names.keys():
        topnav = html.Div(
            html.H1(""),
            className="login-title"
        )
        return new_login(topnav)

    # show the app
    else:
        greeting_and_logout_button = dbc.Row(
            [
                dbc.Col(
                    html.Span(
                        user_names[session_cookie],
                        id="username-greeting",
                    )
                ),
                dbc.Col(
                    dcc.LogoutButton(
                        logout_url="/logout",
                        className="btn btn-outline-dark"
                    ),
                    width="auto",
                )
            ],
            no_gutters=True,
            className="ml-auto flex-nowrap mt-3 mt-md-0",
            align="center",
        )

        topnav = dbc.Navbar([
            dbc.NavbarBrand(
                NAVBAR_TITLE,
                className="ml-2 title-style",
            ),
            dbc.NavbarBrand(
                NAVBAR_SUBTITLE,
                className="ml-2 subtitle_style"
            ),
            greeting_and_logout_button,
        ],
            color="light",
            light=True,
            id="navbar",
            sticky=True,
        )

        user_df = load_dataframe(session_cookie)
        transaction_category_array = list(user_df.Category.unique())
        budget_df = load_budget_dataframe(session_cookie)
        my_table = table_from_dataframe(user_df)

        json_user_df = user_df.to_json(date_format='iso', orient='split')
        json_budget_df = budget_df.to_json(date_format='iso', orient='split')

        return html.Div([
            html.Div(
                topnav,
                id="top-nav",
            ),
            html.Div(
                layout(user_df,
                       transaction_category_array,
                       {},
                       my_table),
                id="app-content",
            ),
            html.Div(
                json_user_df,
                id="hidden-dataframe",
                className="hiddenDiv",
            ),
            html.Div(
                transaction_category_array,
                id="hidden-transaction-category-array",
                className="hiddenDiv",
            ),
            html.Div(
                json_budget_df,
                id="hidden-budget-data",
                className="hiddenDiv",
            ),
        ])
示例#11
0
def render_content(data, tab, start_date, end_date):
    session_cookie = flask.request.cookies.get('custom-auth-session')

    if not session_cookie:
        # If there's no cookie we need to login.
        return [
            html.Div(html.H2(
                "Charts will be displayed here after user's authentication."),
                     style={
                         'textAlign': 'center',
                         'color': 'red'
                     }), '', login_form
        ]
    else:
        df = pd.read_json(data, orient='split')
        data_table = get_data_table(df)
        df = df[(df.date >= start_date) & (df.date <= end_date)]
        logout_output = html.Div(children=[
            html.Div(html.H3('Hello {} !'.format(user_names[session_cookie])),
                     style={'display': 'inline-block'}),
            html.Div(dcc.LogoutButton(logout_url='/logout'),
                     style={'display': 'inline-block'})
        ],
                                 style={
                                     'color': 'green',
                                     'height': '50px'
                                 })
        graph_output = ''

    if tab == 'tab-1':
        return [
            html.Div([
                html.H3(
                    dcc.Graph(id='SMA',
                              figure={
                                  'data': [
                                      {
                                          'x': df['date'],
                                          'y': df['price'],
                                          'type': 'line',
                                          'name': 'Price'
                                      },
                                      {
                                          'x': df['date'],
                                          'y': df['SMA'],
                                          'type': 'line',
                                          'name': 'SMA',
                                          'secondary_y': True
                                      },
                                  ],
                                  'layout': {
                                      'title': 'Simple Moving Average',
                                      'height': 700,
                                      'xaxis': x_axis,
                                      'yaxis': y_axis,
                                      'plot_bgcolor': colors['background2'],
                                      'paper_bgcolor': colors['background'],
                                      'font': {
                                          'color': colors['text'],
                                          'size': 18
                                      }
                                  }
                              })),
            ]), data_table
        ]
    elif tab == 'tab-2':
        return [
            html.Div([
                html.H3(
                    dcc.Graph(id='BVOL',
                              figure={
                                  'data': [
                                      {
                                          'x': df['date'],
                                          'y': df['price'],
                                          'type': 'line',
                                          'name': 'Price'
                                      },
                                      {
                                          'x': df['date'],
                                          'y': df['BVOL_Index'],
                                          'type': 'line',
                                          'name': 'VOL Index',
                                          'yaxis': 'y2'
                                      },
                                  ],
                                  'layout': {
                                      'title': 'Volatility Index',
                                      'height': 700,
                                      'plot_bgcolor': colors['background2'],
                                      'paper_bgcolor': colors['background'],
                                      'font': {
                                          'color': colors['text'],
                                          'size': 18
                                      },
                                      'legend': {
                                          'x': 1.04,
                                          'y': 1.04
                                      },
                                      'xaxis': x_axis,
                                      'yaxis': y_axis,
                                      'yaxis2': {
                                          'title': 'Volatility Index',
                                          'titlefont': {
                                              'color': 'orange'
                                          },
                                          'tickfont': {
                                              'color': 'orange'
                                          },
                                          'overlaying': 'y',
                                          'side': 'right',
                                          'showspikes': True,
                                          'spikedash': 'dot',
                                          'spikemode': 'across',
                                          'spikesnap': 'cursor',
                                      },
                                  }
                              })),
            ]), data_table
        ]
    elif tab == 'tab-3':
        return [
            html.Div([
                html.H3(
                    dcc.Graph(id='RSI',
                              figure={
                                  'data': [
                                      {
                                          'x': df['date'],
                                          'y': df['price'],
                                          'type': 'line',
                                          'name': 'Price'
                                      },
                                      {
                                          'x': df['date'],
                                          'y': df['RSI'],
                                          'type': 'line',
                                          'name': 'RSI',
                                          'yaxis': 'y2'
                                      },
                                  ],
                                  'layout': {
                                      'title': 'Relative Strength Index',
                                      'height': 700,
                                      'plot_bgcolor': colors['background2'],
                                      'paper_bgcolor': colors['background'],
                                      'font': {
                                          'color': colors['text'],
                                          'size': 18
                                      },
                                      'legend': {
                                          'x': 1.04,
                                          'y': 1.04
                                      },
                                      'xaxis': x_axis,
                                      'yaxis': y_axis,
                                      'yaxis2': {
                                          'title': 'Relative Strength Index',
                                          'titlefont': {
                                              'color': 'orange'
                                          },
                                          'tickfont': {
                                              'color': 'orange'
                                          },
                                          'overlaying': 'y',
                                          'side': 'right',
                                          'showspikes': True,
                                          'spikedash': 'dot',
                                          'spikemode': 'across',
                                          'spikesnap': 'cursor',
                                      },
                                  }
                              })),
            ]), data_table
        ]
    elif tab == 'tab-4':
        return [
            html.Div([
                html.H3(
                    dcc.Graph(
                        id='MACD',
                        figure={
                            'data': [
                                {
                                    'x': df['date'],
                                    'y': df['price'],
                                    'type': 'line',
                                    'name': 'Price'
                                },
                                {
                                    'x': df['date'],
                                    'y': df['MACD'],
                                    'type': 'line',
                                    'name': 'MACD',
                                    'yaxis': 'y2'
                                },
                            ],
                            'layout': {
                                'title':
                                'Moving Average Divergence Convergence',
                                'height': 700,
                                'plot_bgcolor': colors['background2'],
                                'paper_bgcolor': colors['background'],
                                'font': {
                                    'color': colors['text'],
                                    'size': 18
                                },
                                'legend': {
                                    'x': 1.04,
                                    'y': 1.04
                                },
                                'xaxis': x_axis,
                                'yaxis': y_axis,
                                'yaxis2': {
                                    'title':
                                    'Moving Average Divergence Convergence',
                                    'titlefont': {
                                        'color': 'orange'
                                    },
                                    'tickfont': {
                                        'color': 'orange'
                                    },
                                    'overlaying': 'y',
                                    'side': 'right',
                                    'showspikes': True,
                                    'spikedash': 'dot',
                                    'spikemode': 'across',
                                    'spikesnap': 'cursor',
                                },
                            }
                        })),
            ]), data_table
        ]
    elif tab == 'tab-5':
        return [
            html.Div([
                html.H3(
                    dcc.Graph(id='EMA',
                              figure={
                                  'data': [
                                      {
                                          'x': df['date'],
                                          'y': df['price'],
                                          'type': 'line',
                                          'name': 'Price'
                                      },
                                      {
                                          'x': df['date'],
                                          'y': df['EMA_20'],
                                          'type': 'line',
                                          'name': 'EMA-20'
                                      },
                                      {
                                          'x': df['date'],
                                          'y': df['EMA_50'],
                                          'type': 'line',
                                          'name': 'EMA-50'
                                      },
                                  ],
                                  'layout': {
                                      'title': 'Exponential Moving Average',
                                      'height': 700,
                                      'xaxis': x_axis,
                                      'yaxis': y_axis,
                                      'plot_bgcolor': colors['background2'],
                                      'paper_bgcolor': colors['background'],
                                      'font': {
                                          'color': colors['text'],
                                          'size': 18
                                      }
                                  }
                              })),
            ]), data_table
        ]
    elif tab == 'tab-6':
        return [
            html.Div([
                html.H3(
                    dcc.Graph(id='SMA',
                              figure={
                                  'data': [
                                      {
                                          'x': df['date'],
                                          'y': df['price'],
                                          'type': 'line',
                                          'name': 'Price'
                                      },
                                      {
                                          'x': df['date'],
                                          'y': df['BB_upper'],
                                          'type': 'line',
                                          'name': 'Upper BB'
                                      },
                                      {
                                          'x': df['date'],
                                          'y': df['BB_lower'],
                                          'type': 'line',
                                          'name': 'Upper BB'
                                      },
                                  ],
                                  'layout': {
                                      'title': 'Bollinger Bands',
                                      'height': 700,
                                      'xaxis': x_axis,
                                      'yaxis': y_axis,
                                      'plot_bgcolor': colors['background2'],
                                      'paper_bgcolor': colors['background'],
                                      'font': {
                                          'color': colors['text'],
                                          'size': 18
                                      }
                                  }
                              })),
            ]), data_table
        ]
示例#12
0
@app.server.route('/auth/logout', methods=['POST'])
def route_logout():
    # Redirect back to the index and remove the session cookie.
    rep = flask.redirect('/')
    rep.set_cookie('auth-session', '', expires=0)
    return rep


app.layout = html.Div([
    dcc.Location(id='url', refresh=False),
    html.Div(id='session_id', style={'display': 'none'}),
    html.Div(id='current-username', style={'display': 'none'}),
    html.Div([
        html.Span('Virtual Stock Exchange', className='app-title'),
        dcc.LogoutButton(id='header-button',
                         logout_url='/auth/logout',
                         style={'float': 'right'})
    ],
             id='custom-header',
             className='header'),
    html.Div(id='page-content')
])

index_layout = html.Div([
    html.Div([
        html.H2('Login', className='stripe-4'),
        html.Form([
            dcc.Input(id='input-user',
                      type='text',
                      placeholder='Enter username',
                      name='username',
示例#13
0
def render_content(data, tab, start_date, end_date):
    session_cookie = flask.request.cookies.get("custom-auth-session")

    if not session_cookie:
        # If there's no cookie we need to login.
        return [
            html.Div(
                html.
                H2("Charts will be displayed here after user's authentication."
                   ),
                style={
                    "textAlign": "center",
                    "color": "red"
                },
            ),
            "",
            login_form,
        ]
    else:
        df = pd.read_json(data, orient="split")
        data_table = get_data_table(df)
        df = df[(df.date >= start_date) & (df.date <= end_date)]
        logout_output = html.Div(
            children=[
                html.Div(
                    html.H3("Hello {} !".format(user_names[session_cookie])),
                    style={"display": "inline-block"},
                ),
                html.Div(
                    dcc.LogoutButton(logout_url="/logout"),
                    style={"display": "inline-block"},
                ),
            ],
            style={
                "color": "green",
                "height": "50px"
            },
        )
        graph_output = ""

        if tab == "tab-1":
            graph_output = html.Div([
                html.H3(
                    dcc.Graph(
                        id="SMA",
                        figure={
                            "data": [
                                {
                                    "x": df["date"],
                                    "y": df["price"],
                                    "type": "line",
                                    "name": "Price",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["SMA"],
                                    "type": "line",
                                    "name": "SMA",
                                    "secondary_y": True,
                                },
                            ],
                            "layout": {
                                "title": "Simple Moving Average",
                                "height": 700,
                                "xaxis": x_axis,
                                "yaxis": y_axis,
                                "plot_bgcolor": colors["background2"],
                                "paper_bgcolor": colors["background"],
                                "font": {
                                    "color": colors["text"],
                                    "size": 18,
                                },
                            },
                        },
                    ))
            ])
        elif tab == "tab-2":
            graph_output = html.Div([
                html.H3(
                    dcc.Graph(
                        id="BVOL",
                        figure={
                            "data": [
                                {
                                    "x": df["date"],
                                    "y": df["price"],
                                    "type": "line",
                                    "name": "Price",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["BVOL_Index"],
                                    "type": "line",
                                    "name": "VOL Index",
                                    "yaxis": "y2",
                                },
                            ],
                            "layout": {
                                "title": "Volatility Index",
                                "height": 700,
                                "plot_bgcolor": colors["background2"],
                                "paper_bgcolor": colors["background"],
                                "font": {
                                    "color": colors["text"],
                                    "size": 18,
                                },
                                "legend": {
                                    "x": 1.04,
                                    "y": 1.04
                                },
                                "xaxis": x_axis,
                                "yaxis": y_axis,
                                "yaxis2": {
                                    "title": "Volatility Index",
                                    "titlefont": {
                                        "color": "orange"
                                    },
                                    "tickfont": {
                                        "color": "orange"
                                    },
                                    "overlaying": "y",
                                    "side": "right",
                                    "showspikes": True,
                                    "spikedash": "dot",
                                    "spikemode": "across",
                                    "spikesnap": "cursor",
                                },
                            },
                        },
                    )),
            ])
        elif tab == "tab-3":
            graph_output = html.Div([
                html.H3(
                    dcc.Graph(
                        id="RSI",
                        figure={
                            "data": [
                                {
                                    "x": df["date"],
                                    "y": df["price"],
                                    "type": "line",
                                    "name": "Price",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["RSI"],
                                    "type": "line",
                                    "name": "RSI",
                                    "yaxis": "y2",
                                },
                            ],
                            "layout": {
                                "title": "Relative Strength Index",
                                "height": 700,
                                "plot_bgcolor": colors["background2"],
                                "paper_bgcolor": colors["background"],
                                "font": {
                                    "color": colors["text"],
                                    "size": 18,
                                },
                                "legend": {
                                    "x": 1.04,
                                    "y": 1.04
                                },
                                "xaxis": x_axis,
                                "yaxis": y_axis,
                                "yaxis2": {
                                    "title": "Relative Strength Index",
                                    "titlefont": {
                                        "color": "orange"
                                    },
                                    "tickfont": {
                                        "color": "orange"
                                    },
                                    "overlaying": "y",
                                    "side": "right",
                                    "showspikes": True,
                                    "spikedash": "dot",
                                    "spikemode": "across",
                                    "spikesnap": "cursor",
                                },
                            },
                        },
                    )),
            ])
        elif tab == "tab-4":
            graph_output = html.Div([
                html.H3(
                    dcc.Graph(
                        id="MACD",
                        figure={
                            "data": [
                                {
                                    "x": df["date"],
                                    "y": df["price"],
                                    "type": "line",
                                    "name": "Price",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["MACD"],
                                    "type": "line",
                                    "name": "MACD",
                                    "yaxis": "y2",
                                },
                            ],
                            "layout": {
                                "title":
                                "Moving Average Divergence Convergence",
                                "height": 700,
                                "plot_bgcolor": colors["background2"],
                                "paper_bgcolor": colors["background"],
                                "font": {
                                    "color": colors["text"],
                                    "size": 18,
                                },
                                "legend": {
                                    "x": 1.04,
                                    "y": 1.04
                                },
                                "xaxis": x_axis,
                                "yaxis": y_axis,
                                "yaxis2": {
                                    "title":
                                    "Moving Average Divergence Convergence",
                                    "titlefont": {
                                        "color": "orange"
                                    },
                                    "tickfont": {
                                        "color": "orange"
                                    },
                                    "overlaying": "y",
                                    "side": "right",
                                    "showspikes": True,
                                    "spikedash": "dot",
                                    "spikemode": "across",
                                    "spikesnap": "cursor",
                                },
                            },
                        },
                    )),
            ])
        elif tab == "tab-5":
            graph_output = html.Div([
                html.H3(
                    dcc.Graph(
                        id="EMA",
                        figure={
                            "data": [
                                {
                                    "x": df["date"],
                                    "y": df["price"],
                                    "type": "line",
                                    "name": "Price",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["EMA_20"],
                                    "type": "line",
                                    "name": "EMA-20",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["EMA_50"],
                                    "type": "line",
                                    "name": "EMA-50",
                                },
                            ],
                            "layout": {
                                "title": "Exponential Moving Average",
                                "height": 700,
                                "xaxis": x_axis,
                                "yaxis": y_axis,
                                "plot_bgcolor": colors["background2"],
                                "paper_bgcolor": colors["background"],
                                "font": {
                                    "color": colors["text"],
                                    "size": 18,
                                },
                            },
                        },
                    )),
            ])
        elif tab == "tab-6":
            graph_output = html.Div([
                html.H3(
                    dcc.Graph(
                        id="SMA",
                        figure={
                            "data": [
                                {
                                    "x": df["date"],
                                    "y": df["price"],
                                    "type": "line",
                                    "name": "Price",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["BB_upper"],
                                    "type": "line",
                                    "name": "Upper BB",
                                },
                                {
                                    "x": df["date"],
                                    "y": df["BB_lower"],
                                    "type": "line",
                                    "name": "Upper BB",
                                },
                            ],
                            "layout": {
                                "title": "Bollinger Bands",
                                "height": 700,
                                "xaxis": x_axis,
                                "yaxis": y_axis,
                                "plot_bgcolor": colors["background2"],
                                "paper_bgcolor": colors["background"],
                                "font": {
                                    "color": colors["text"],
                                    "size": 18,
                                },
                            },
                        },
                    )),
            ])
        return [graph_output, data_table, logout_output]
示例#14
0
from utils import *
from appConfig import jokes_folder
import dash_core_components as dcc

layout = html.Div([

    # header
    html.Div([
        html.Span("APP Title", className='app-title'),
        html.Span(dcc.LogoutButton(logout_url='/custom-auth/logout',
                                   style={"background-color": 'black'}),
                  style={"float": "Right"},
                  className='app-title')
    ],
             className="row header"),
    html.Div(children=[
        html.Div(id='page-content',
                 className='container',
                 style={"margin": "2% 3%"}),
        html.Div([
            dcc.RadioItems(id='rating',
                           options=[
                               {
                                   'label': 'Bad Joke',
                                   'value': '1'
                               },
                               {
                                   'label': 'Ok Joke',
                                   'value': '2'
                               },
                               {
示例#15
0
import dash_core_components as dcc
import dash_html_components as html

from dash.dependencies import Input, Output
from flask import Flask, session
from flask_keycloak import FlaskKeycloak

# Read config path from cmd if provided.
config_path = None if len(sys.argv) < 2 else sys.argv[1]
# Setup server.
server = Flask(__name__)
FlaskKeycloak.from_kc_oidc_json(server,
                                "http://*****:*****@app.callback(Output('greeting', 'children'), [Input('main', 'children')])
def update_greeting(input_value):
    user = session["userinfo"]
    return "Hello {}".format(user['preferred_username'])


if __name__ == '__main__':
    app.run_server(port=5000)