how to fix flask cache issue in python

Solutions on MaxInterview for how to fix flask cache issue in python by the best coders in the world

showing results for - "how to fix flask cache issue in python"
Jannik
15 Oct 2016
1# fix flask cache issue
2from flask import *
3
4import os
5
6# default root : http://127.0.0.1:5000/
7
8app = Flask(__name__)
9
10#----------------------------------------------------
11##   FIRST METHOD
12
13##   You can simply set this to 0
14# app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
15
16# @app.route("/", methods=["POST", "GET"])
17# def home():
18#     return render_template("index.html")
19#---------------------------------------------------
20#---------------------------------------------------
21#	SECOND METHOD
22#   This gets the last version of the cache
23#   I've tried this method and it works
24def dir_last_updated(folder):
25    return str(max(os.path.getmtime(os.path.join(root_path, f))
26                   for root_path, dirs, files in os.walk(folder)
27                   for f in files))
28
29@app.route("/", methods=["POST", "GET"])
30def home():
31#   Get the current path of the program
32    path = os.getcwd()
33    path = path.replace('\\', '/')
34#   Now you set last_updated to the last cache
35    return render_template("index.html", last_updated=dir_last_updated(path+"/static"))
36
37
38if __name__ == "__main__":
39    app.run(debug=True)
40