1+ """Create a Dash app within a Flask app."""
12import glob
2- from pathlib import Path , PurePath
3+ from pathlib import Path
34from dash import Dash
45import dash_table
5- import dash_core_components as dcc
66import dash_html_components as html
77import pandas as pd
8-
9- p = Path ('.' )
8+ from .layout import html_layout
109
1110
1211def Add_Dash (server ):
@@ -22,27 +21,7 @@ def Add_Dash(server):
2221 routes_pathname_prefix = '/dashapp/' )
2322
2423 # Override the underlying HTML template
25- dash_app .index_string = '''<!DOCTYPE html>
26- <html>
27- <head>
28- {%metas%}
29- <title>{%title%}</title>
30- {%favicon%}
31- {%css%}
32- </head>
33- <body>
34- <nav>
35- <a href="/"><i class="fas fa-home"></i> Home</a>
36- <a href="/dashapp/"><i class="fas fa-chart-line"></i> Embdedded Plotly Dash</a>
37- </nav>
38- {%app_entry%}
39- <footer>
40- {%config%}
41- {%scripts%}
42- {%renderer%}
43- </footer>
44- </body>
45- </html>'''
24+ dash_app .index_string = html_layout
4625
4726 # Create Dash Layout comprised of Data Tables
4827 dash_app .layout = html .Div (
@@ -55,10 +34,10 @@ def Add_Dash(server):
5534
5635def get_datasets ():
5736 """Return previews of all CSVs saved in /data directory."""
37+ p = Path ('.' )
5838 data_filepath = list (p .glob ('data/*.csv' ))
5939 arr = ['This is an example Plot.ly Dash App.' ]
6040 for index , csv in enumerate (data_filepath ):
61- print (PurePath (csv ))
6241 df = pd .read_csv (data_filepath [index ]).head (10 )
6342 table_preview = dash_table .DataTable (
6443 id = 'table_' + str (index ),
0 commit comments