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 = {}
|
||||
|
||||
@app.route("/r")
|
||||
def updateData():
|
||||
global data
|
||||
out = []
|
||||
|
||||
f = zipfile.ZipFile("library.tc")
|
||||
@ -63,16 +65,19 @@ def updateData():
|
||||
else:
|
||||
bookout[datum] = ""
|
||||
out.append(bookout.copy())
|
||||
return out.copy()
|
||||
data = out.copy()
|
||||
return "success"
|
||||
|
||||
@app.route("/")
|
||||
def main():
|
||||
data = updateData();
|
||||
if data == []:
|
||||
updateData()
|
||||
return render_template("main.html", books = data, attributes = attributes)
|
||||
|
||||
@app.route("/book/<int:id>")
|
||||
def book(id):
|
||||
data = updateData();
|
||||
if data == []:
|
||||
updateData()
|
||||
book = next((item for item in data if int(item["id"]) == id), {})
|
||||
return render_template("book.html", book = book, fields = fields)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user