flask-cache

This commit is contained in:
David Itehua Xalamihua 2025-04-29 14:09:08 -06:00
parent c6ca569415
commit fe97fd320e
2 changed files with 10 additions and 1 deletions

View File

@ -19,8 +19,11 @@ import re
import json import json
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from functools import wraps from functools import wraps
from flask_caching import Cache
app = Flask(__name__) app = Flask(__name__)
cache = Cache(app, config={'CACHE_TYPE': 'filesystem', 'CACHE_DIR': '/tmp/flask-formha'})
bcrypt = Bcrypt(app) bcrypt = Bcrypt(app)
# csrf = CSRFProtect(app) # csrf = CSRFProtect(app)
@ -108,7 +111,6 @@ def validate_user_exists(f):
return decorated_function return decorated_function
# ################################################################## # ##################################################################
# #
# /$$$$$$ /$$$$$$$$ /$$ /$$ /$$$$$$$$ /$$$$$$$ /$$$$$$ /$$ # /$$$$$$ /$$$$$$$$ /$$ /$$ /$$$$$$$$ /$$$$$$$ /$$$$$$ /$$
@ -124,23 +126,28 @@ def validate_user_exists(f):
# ################################################################## # ##################################################################
@app.route('/') @app.route('/')
@cache.cached(timeout=3600)
def home(): def home():
return render_template(v['home'], active_page='home') return render_template(v['home'], active_page='home')
@app.route('/about-us') @app.route('/about-us')
@cache.cached(timeout=43200)
def about_us(): def about_us():
return render_template(v['about-us'], active_page='about_us') return render_template(v['about-us'], active_page='about_us')
@app.route('/solutions') @app.route('/solutions')
@cache.cached(timeout=43200)
def solutions(): def solutions():
return render_template(v['solutions'], active_page='solutions') return render_template(v['solutions'], active_page='solutions')
@app.route('/methodology') @app.route('/methodology')
@cache.cached(timeout=43200)
def methodology(): def methodology():
return render_template(v['methodology'], active_page='methodology') return render_template(v['methodology'], active_page='methodology')
@app.route('/blog') @app.route('/blog')
@cache.cached(timeout=2880)
def blog(): def blog():
# if any(x in search for x in ["'", '"', " OR ", "--", ";", "1=1"]): # if any(x in search for x in ["'", '"', " OR ", "--", ";", "1=1"]):

View File

@ -1,11 +1,13 @@
bcrypt==4.3.0 bcrypt==4.3.0
beautifulsoup4==4.13.3 beautifulsoup4==4.13.3
blinker==1.9.0 blinker==1.9.0
cachelib==0.13.0
click==8.1.8 click==8.1.8
dnspython==2.7.0 dnspython==2.7.0
email_validator==2.2.0 email_validator==2.2.0
Flask==3.1.0 Flask==3.1.0
Flask-Bcrypt==1.0.1 Flask-Bcrypt==1.0.1
Flask-Caching==2.3.1
Flask-JWT-Extended==4.7.1 Flask-JWT-Extended==4.7.1
Flask-Mail==0.10.0 Flask-Mail==0.10.0
Flask-WTF==1.2.2 Flask-WTF==1.2.2