Skip to content

Commit 3f5d1c2

Browse files
committed
refactor
1 parent 85fca9f commit 3f5d1c2

File tree

24 files changed

+1430
-369
lines changed

24 files changed

+1430
-369
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
__pycache__
44
.ropeproject
55
.idea
6-
data
76
.webassets-cache

plotly_flask_tutorial/dash_view.py renamed to Dash_App/dash_view.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010

1111

1212
def Add_Dash(server):
13-
"""Plot.ly Dash view which populates the screen with loaded DataFrames."""
14-
external_stylesheets = ['https://hackers.nyc3.cdn.digitaloceanspaces.com/css/plotly-flask-tutorial.css',
13+
"""Create a Dash app."""
14+
external_stylesheets = ['/static/dist/css/plotly-flask-tutorial.css',
1515
'https://fonts.googleapis.com/css?family=Lato',
1616
'https://use.fontawesome.com/releases/v5.8.1/css/all.css']
17+
external_scripts = ['/static/dist/js/includes/jquery.min.js',
18+
'/static/dist/js/main.js']
1719
dash_app = Dash(server=server,
1820
external_stylesheets=external_stylesheets,
19-
routes_pathname_prefix='/dash_view/')
21+
external_scripts=external_scripts,
22+
routes_pathname_prefix='/dashapp/')
2023

2124
# Override the underlying HTML template
2225
dash_app.index_string = '''<!DOCTYPE html>
@@ -30,7 +33,7 @@ def Add_Dash(server):
3033
<body>
3134
<nav>
3235
<a href="/"><i class="fas fa-home"></i> Home</a>
33-
<a href="/dash_view/"><i class="fas fa-chart-line"></i> Embdedded Plotly Dash</a>
36+
<a href="/dashapp/"><i class="fas fa-chart-line"></i> Embdedded Plotly Dash</a>
3437
</nav>
3538
{%app_entry%}
3639
<footer>
@@ -44,15 +47,15 @@ def Add_Dash(server):
4447
# Create Dash Layout comprised of Data Tables
4548
dash_app.layout = html.Div(
4649
children=get_datasets(),
47-
id='flex-container'
50+
id='dash-container'
4851
)
4952

5053
return dash_app.server
5154

5255

5356
def get_datasets():
54-
"""Returns previews of all CSVs saved in /data directory."""
55-
data_filepath = list(p.glob('plotly_flask_tutorial/data/*.csv'))
57+
"""Return previews of all CSVs saved in /data directory."""
58+
data_filepath = list(p.glob('data/*.csv'))
5659
arr = ['This is an example Plot.ly Dash App.']
5760
for index, csv in enumerate(data_filepath):
5861
print(PurePath(csv))

Pipfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ verify_ssl = true
55

66
[dev-packages]
77
python-dotenv="*"
8+
lesscpy="*"
9+
cssmin="*"
10+
jsmin="*"
811

912
[packages]
1013
flask="*"
@@ -15,10 +18,6 @@ dash_core_components="*"
1518
dash_html_components="*"
1619
dash-renderer="*"
1720
pandas="*"
18-
lesscpy="*"
19-
cssmin="*"
20-
jsmin="*"
21-
2221

2322
[requires]
2423
python_version = "3.7"

Pipfile.lock

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
"""Initialize app."""
12
from flask import Flask
2-
from . import dash_view
33

44

55
def create_app():
66
"""Construct the core application."""
77
app = Flask(__name__, instance_relative_config=False)
88
app.config.from_object('config.Config')
9-
dash_app = dash_view.Add_Dash(app)
109

1110
with app.app_context():
1211

1312
# Construct the data set
1413
from . import routes
14+
from Dash_App import dash_view
15+
app = dash_view.Add_Dash(app)
1516
app.register_blueprint(routes.main_bp)
1617

1718
return app

plotly_flask_tutorial/routes.py renamed to application/routes.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
"""Routes for core Flask app."""
12
import os
23
from flask import Blueprint, render_template
34
from flask_assets import Environment, Bundle
45
from flask import current_app as app
5-
import lesscpy
66

77
main_bp = Blueprint('main_bp', __name__,
88
template_folder='templates',
@@ -12,20 +12,21 @@
1212
Environment.debug = False
1313
less_bundle = Bundle('less/*.less',
1414
filters='less,cssmin',
15-
output='dist/css/plotly-flask-tutorial.css.css',
15+
output='dist/css/plotly-flask-tutorial.css',
1616
extra={'rel': 'stylesheet/less'})
1717
js_bundle = Bundle('js/*.js',
1818
filters='jsmin',
1919
output='dist/js/main.js')
2020
assets.register('less_all', less_bundle)
2121
assets.register('js_all', js_bundle)
22-
# less_bundle.build(force=True)
23-
js_bundle.build()
22+
if app.config['FLASK_ENV'] == 'development':
23+
less_bundle.build(force=True)
24+
js_bundle.build()
2425

2526

26-
# Landing Page
27-
@main_bp.route('/', methods=['GET'])
27+
@main_bp.route('/')
2828
def home():
29+
"""Landing page."""
2930
return render_template('index.html',
3031
title='Plotly Flask Tutorial.',
3132
template='home-template',

application/static/dist/css/plotly-flask-tutorial.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)