move updateData to /r page, only call when needed
This commit is contained in:
parent
ab6b9bd247
commit
af09386e83
11
test.py
11
test.py
|
@ -12,7 +12,9 @@ attributes= ["title",
|
||||||
|
|
||||||
fields = {}
|
fields = {}
|
||||||
|
|
||||||
|
@app.route("/r")
|
||||||
def updateData():
|
def updateData():
|
||||||
|
global data
|
||||||
out = []
|
out = []
|
||||||
|
|
||||||
f = zipfile.ZipFile("library.tc")
|
f = zipfile.ZipFile("library.tc")
|
||||||
|
@ -63,16 +65,19 @@ def updateData():
|
||||||
else:
|
else:
|
||||||
bookout[datum] = ""
|
bookout[datum] = ""
|
||||||
out.append(bookout.copy())
|
out.append(bookout.copy())
|
||||||
return out.copy()
|
data = out.copy()
|
||||||
|
return "success"
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def main():
|
def main():
|
||||||
data = updateData();
|
if data == []:
|
||||||
|
updateData()
|
||||||
return render_template("main.html", books = data, attributes = attributes)
|
return render_template("main.html", books = data, attributes = attributes)
|
||||||
|
|
||||||
@app.route("/book/<int:id>")
|
@app.route("/book/<int:id>")
|
||||||
def book(id):
|
def book(id):
|
||||||
data = updateData();
|
if data == []:
|
||||||
|
updateData()
|
||||||
book = next((item for item in data if int(item["id"]) == id), {})
|
book = next((item for item in data if int(item["id"]) == id), {})
|
||||||
return render_template("book.html", book = book, fields = fields)
|
return render_template("book.html", book = book, fields = fields)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue