From af09386e83c7f82ec6f92e7c023725fd7c1d24f2 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 13 Aug 2015 11:18:51 -0400 Subject: [PATCH] move updateData to /r page, only call when needed --- test.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index 3808cbd..23671c2 100644 --- a/test.py +++ b/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/") 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)