from flask import Flask
from flask import Blueprint
from flask_caching import Cache
config = {
"DEBUG": True, # some Flask specific configs
"CACHE_TYPE": "SimpleCache", # Flask-Caching related configs
"CACHE_DEFAULT_TIMEOUT": 300
}
user = Blueprint('main', __name__)
cache = Cache(config=config)
app = Flask(__name__)
cache.init_app(app)
def key_prefix_func():
with current_app.app_context():
cache_key = request.url
return cache_key
@user.route("/", methods=["GET", "POST"])
@cache.cached(timeout=60*60, key_prefix=key_prefix_func)
def home():
print(">>>>>>>>>>>>>>>>>>")
return "hello word"