-
Notifications
You must be signed in to change notification settings - Fork 6
/
usage.py
48 lines (31 loc) · 1.23 KB
/
usage.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
from app import create_dash
from dash_spa import logging, config, DashSPA, page_container
from server import serve_app
from dash_spa_admin import AdminLoginManager
options = config.get('logging')
def create_app(dash_factory) -> DashSPA:
"""Create Dash application
Args:
dash_factory (Dash): Callable that returns a Dash Instance
Returns:
Dash: Dash instance
"""
app = dash_factory()
def layout():
return page_container
app.layout = layout
if AdminLoginManager.enabled:
login_manager = AdminLoginManager(app.server)
login_manager.init_app(app.server)
# Optionally add admin user here or via the admin web interface
# if login_manager.user_count() == 0:
# login_manager.add_user("admin", "bigjoe@gmail.com", "1234", role=['admin'])
# Other users can also be added here. Alternatively login as 'admin'
# and manage users from the users view.
# if not login_manager.get_user("littlejoe@gmail.com"):
# login_manager.add_user("littlejoe", "littlejoe@gmail.com", "5678")
return app
if __name__ == "__main__":
logging.setLevel(options.level)
app = create_app(create_dash)
serve_app(app, debug=False)