From c6531fd15f7067d8c75a2b948a209a8985d5e57f Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Sun, 17 Oct 2021 23:28:25 -0600 Subject: [PATCH] dashboard requires login --- flaskfdx/__init__.py | 5 +++++ flaskfdx/dashboard.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/flaskfdx/__init__.py b/flaskfdx/__init__.py index faf6479..9191876 100644 --- a/flaskfdx/__init__.py +++ b/flaskfdx/__init__.py @@ -23,6 +23,11 @@ def create_app(test_config=None): except OSError: pass + # simple hello page + @app.route('/hello') + def hello(): + return 'Hello, World!' + from . import db db.init_app(app) diff --git a/flaskfdx/dashboard.py b/flaskfdx/dashboard.py index d7275be..3f1df6d 100644 --- a/flaskfdx/dashboard.py +++ b/flaskfdx/dashboard.py @@ -11,12 +11,14 @@ from flaskfdx.db import get_db bp = Blueprint('dashboard', __name__) @bp.route('/') +@login_required def index(): db = get_db() fourweeks = db.execute( 'SELECT * FROM totals ORDER BY date DESC LIMIT 56' ).fetchall() lastseven = {} + stops = 0 for row in fourweeks: if row['date'] not in lastseven: lastseven[row['date']] = {} @@ -31,3 +33,11 @@ def index(): lastseven[row['date']]['percenttermvol'] = round(100 * stops / row['prepkgs'], 2) return render_template('dashboard/index.html', lastseven=lastseven) + +@bp.route('/upload', methods=('GET', 'POST')) +@login_required +def upload(): + if request.method == 'POST': + file = request.form['file'] + + return render_template('dashboard/upload.html')