Skip to content

Commit 9323d9b

Browse files
committed
added docstrings, general cleanup
1 parent 745c31d commit 9323d9b

File tree

7 files changed

+32
-29
lines changed

7 files changed

+32
-29
lines changed

application/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
def create_app():
66
"""Construct the core application."""
7-
app = Flask(__name__, instance_relative_config=False)
7+
app = Flask(__name__,
8+
instance_relative_config=False)
89
app.config.from_object('config.Config')
910

1011
with app.app_context():

application/dash_application/dash_example.py

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
"""Create a Dash app within a Flask app."""
12
import glob
2-
from pathlib import Path, PurePath
3+
from pathlib import Path
34
from dash import Dash
45
import dash_table
5-
import dash_core_components as dcc
66
import dash_html_components as html
77
import pandas as pd
8-
9-
p = Path('.')
8+
from .layout import html_layout
109

1110

1211
def 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

5635
def 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),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
html_layout = '''<!DOCTYPE html>
2+
<html>
3+
<head>
4+
{%metas%}
5+
<title>{%title%}</title>
6+
{%favicon%}
7+
{%css%}
8+
</head>
9+
<body>
10+
<nav>
11+
<a href="/"><i class="fas fa-home"></i> Home</a>
12+
<a href="/dashapp/"><i class="fas fa-chart-line"></i> Embdedded Plotly Dash</a>
13+
</nav>
14+
{%app_entry%}
15+
<footer>
16+
{%config%}
17+
{%scripts%}
18+
{%renderer%}
19+
</footer>
20+
</body>
21+
</html>'''

application/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def home():
3030
return render_template('index.html',
3131
title='Plotly Flask Tutorial.',
3232
template='home-template',
33-
body="This is an example homepage, served with Flask.")
33+
body="This is an example homepage served with Flask.")

application/static/dist/css/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""App config."""
12
import os
23

34

wsgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Application entry point."""
12
from application import create_app
23

34
app = create_app()

0 commit comments

Comments
 (0)