Skip to content

Commit 03cfb6d

Browse files
committed
Refactor.
1 parent 3ae9d80 commit 03cfb6d

File tree

22 files changed

+643
-21
lines changed

22 files changed

+643
-21
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FLASK_APP=wsgi.py
2+
FLASK_ENV=development
3+
SECRET_KEY=randomstringofcharacters
4+
LESS_BIN=/usr/local/bin/lessc
5+
ASSETS_DEBUG=False
6+
LESS_RUN_IN_DEBUG=False
7+
COMPRESSOR_DEBUG=True

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ $ pipenv update
4141
$ flask run
4242
```
4343

44+
## Usage
45+
46+
Replace the values in **.env.example** with your values and rename this file to **.env**:
47+
48+
* `FLASK_APP`: Entry point of your application (should be `wsgi.py`).
49+
* `FLASK_ENV`: The environment to run your app in (either `development` or `production`).
50+
* `SECRET_KEY`: Randomly generated string of characters used to encrypt your app's data.
51+
* `LESS_BIN`: Path to your local LESS installation via `which lessc` (optional for static assets).
52+
* `ASSETS_DEBUG`: Debug asset creation and bundling in `development` (optional).
53+
* `LESS_RUN_IN_DEBUG`: Debug LESS while in `development` (optional).
54+
* `COMPRESSOR_DEBUG`: Debug asset compression while in `development` (optional).
55+
56+
57+
*Remember never to commit secrets saved in .env files to Github.*
4458

4559
-----
4660

config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class Config:
1010
"""Flask configuration variables."""
1111

1212
# General Config
13-
SECRET_KEY = environ.get('SECRET_KEY')
1413
FLASK_APP = environ.get('FLASK_APP')
1514
FLASK_ENV = environ.get('FLASK_ENV')
15+
SECRET_KEY = environ.get('SECRET_KEY')
1616

1717
# Assets
1818
LESS_BIN = environ.get('LESS_BIN')
1919
ASSETS_DEBUG = environ.get('ASSETS_DEBUG')
2020
LESS_RUN_IN_DEBUG = environ.get('LESS_RUN_IN_DEBUG')
2121

2222
# Static Assets
23-
STATIC_FOLDER = environ.get('STATIC_FOLDER')
24-
TEMPLATES_FOLDER = environ.get('TEMPLATES_FOLDER')
23+
STATIC_FOLDER = 'static'
24+
TEMPLATES_FOLDER = 'templates'
2525
COMPRESSOR_DEBUG = environ.get('COMPRESSOR_DEBUG')
File renamed without changes.

application/assets.py renamed to plotlydash_flask_tutorial/assets.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ def compile_static_assets(assets):
1212
"""
1313
assets.auto_build = True
1414
assets.debug = False
15-
less_bundle = Bundle('less/*.less',
16-
filters='less,cssmin',
17-
output='dist/css/styles.css',
18-
extra={'rel': 'stylesheet/less'})
15+
less_bundle = Bundle(
16+
'less/*.less',
17+
filters='less,cssmin',
18+
output='dist/css/styles.css',
19+
extra={'rel': 'stylesheet/less'}
20+
)
1921
assets.register('less_all', less_bundle)
2022
if app.config['FLASK_ENV'] == 'development':
2123
less_bundle.build()

application/plotlydash/dashboard.py renamed to plotlydash_flask_tutorial/plotlydash/dashboard.py

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

1111
def create_dashboard(server):
1212
"""Create a Plotly Dash dashboard."""
13-
dash_app = dash.Dash(server=server,
14-
routes_pathname_prefix='/dashapp/',
15-
external_stylesheets=[
16-
'/static/dist/css/styles.css',
17-
'https://fonts.googleapis.com/css?family=Lato'
18-
]
19-
)
13+
dash_app = dash.Dash(
14+
server=server,
15+
routes_pathname_prefix='/dashapp/',
16+
external_stylesheets=[
17+
'/static/dist/css/styles.css',
18+
'https://fonts.googleapis.com/css?family=Lato'
19+
]
20+
)
2021

2122
# Prepare a DataFrame
2223
df = pd.read_csv('data/311-calls.csv', parse_dates=['created'])
File renamed without changes.

application/routes.py renamed to plotlydash_flask_tutorial/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Core Flask app routes."""
1+
"""Routes for parent Flask app."""
22
from flask import render_template
33
from flask import current_app as app
44

0 commit comments

Comments
 (0)