From b35c36629fec03ab920862389f60d7821283953c Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Sun, 3 Nov 2024 19:54:56 +0000 Subject: [PATCH] fix caching --- app.py | 16 ++++++++++------ lib/__pycache__/reqs.cpython-310.pyc | Bin 979 -> 1521 bytes 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 11b4d98..dc02270 100644 --- a/app.py +++ b/app.py @@ -14,16 +14,20 @@ app.config.from_object(DevelopmentConfig) # Use DevelopmentConfig or Production cache = Cache(app, config={'CACHE_TYPE': 'SimpleCache'}) @app.route('/') -@cache.cached(timeout=60) # cache for 120 seconds -def home(): +def index(): # If the user is logged in, redirect to a protected page like /accounts if session.get('logged_in'): - base_url = app.config['BASE_URL'] # Access base_url from the config - all_accounts = get_user_accounts(base_url, session['auth_credentials']) - current_month_accounts = filter_accounts_current_month(all_accounts) - return render_template('home.html', username=session['username'], accounts=get_user_accounts(base_url, session['auth_credentials']), current_month_accounts=current_month_accounts) + return redirect(url_for('home')) return render_template('index.html') +@app.route('/home') +@cache.cached(timeout=60) # cache for 120 seconds +def home(): + base_url = app.config['BASE_URL'] # Access base_url from the config + all_accounts = get_user_accounts(base_url, session['auth_credentials']) + current_month_accounts = filter_accounts_current_month(all_accounts) + return render_template('home.html', username=session['username'], accounts=get_user_accounts(base_url, session['auth_credentials']), current_month_accounts=current_month_accounts) + @app.route('/login', methods=['POST']) def login(): username = request.form['username'] diff --git a/lib/__pycache__/reqs.cpython-310.pyc b/lib/__pycache__/reqs.cpython-310.pyc index d8d9a49a45b3c5c0115aabab08958c10ffd1d6e9..7639ac12a6699aa80d915468329a26824de89edf 100644 GIT binary patch delta 863 zcmaJ<&2G~`5caG$_Qv^Xn-aPW9myjs7(XM@48SHuHw;Q$gaV_Jw%)RE@f-Pzfh*_rR7`?awdw_2Ws^5bA*^tNVM zpXo3!bbANY3=TJU*6YfaHmZl(K;_DP=EK({ym1#87O z*oW`MD|Q{q;)HE=n;1^F2-*Zo1k1%2wvn&U)+Xo>tP<1-E+CXbE8|a09F=Y`9L8ys z=q_DWaFIM#Mk?`BqqKkOV3yHrE+KfpSsOa62?97czEtHSDhNwK zA)+8uLyq<{p+X$gd#GjyA+wGw3CC>4GnUzsy56j>v| zEKNNu`NIdhkF}t41EF815#*=Crx&_Muz&{oGF|*P_*JQ