Browse Source

fix caching

Karl Hudgell 1 month ago
parent
commit
b35c36629f
2 changed files with 10 additions and 6 deletions
  1. 10 6
      app.py
  2. BIN
      lib/__pycache__/reqs.cpython-310.pyc

+ 10 - 6
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']

BIN
lib/__pycache__/reqs.cpython-310.pyc