-
Notifications
You must be signed in to change notification settings - Fork 18
/
app.py
executable file
·79 lines (61 loc) · 1.8 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /usr/bin/env python
# Example app
import os
import dash_core_components as dcc
import dash_html_components as html
from dash import Dash
from dash.dependencies import Input, Output
from flask import Flask, session
from dash_google_auth import GoogleOAuth
# configure app
server = Flask(__name__)
app = Dash(
__name__,
server=server,
url_base_pathname='/',
auth='auth',
)
app.config['suppress_callback_exceptions']=True
# configure google oauth using environment variables
server.secret_key = os.environ.get("FLASK_SECRET_KEY", "supersekrit")
server.config["GOOGLE_OAUTH_CLIENT_ID"] = os.environ["GOOGLE_OAUTH_CLIENT_ID"]
server.config["GOOGLE_OAUTH_CLIENT_SECRET"] = os.environ["GOOGLE_OAUTH_CLIENT_SECRET"]
# allow for insecure transport for local testing (remove in prod)
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
# designate list of authorized emails
authorized_emails = [
]
auth = GoogleOAuth(
app,
authorized_emails,
)
@server.route("/")
def MyDashApp():
return app.index()
app.layout = html.Div(children=[
html.H1(children="Private Dash App"),
html.Div(id='placeholder', style={'display':'none'}),
html.Div(id='welcome'),
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 6], 'type': 'bar', 'name': 'Montreal'},
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
@app.callback(
Output('welcome', 'children'),
[Input('placeholder', 'value')]
)
def on_load(value):
return "Welcome, {}!".format(session['email'])
if __name__ == '__main__':
app.run_server(host='localhost')