From f00fe1e54aa853aac503676f37ad77ba2cbc5a1a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 8 Aug 2015 19:26:24 -0400 Subject: [PATCH] move data parsing to its own function --- test.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test.py b/test.py index 3a4806d..0896042 100644 --- a/test.py +++ b/test.py @@ -5,12 +5,13 @@ import zipfile from flask import Flask, render_template app = Flask(__name__) -@app.route("/") -def main(): - out = [] - data = ["title", - "authors", - "isbn"] +data = [] +attributes= ["title", + "authors", + "isbn"] + +def updateData(): + out = [] f = zipfile.ZipFile("library.tc") tree = ElementTree.parse(f.open("tellico.xml")) @@ -28,7 +29,13 @@ def main(): bookout["authors"] = "; ".join(authors) out.append(bookout.copy()) - return render_template("books.html", books = out, data = data) + return out.copy() + +@app.route("/") +def main(): + data = updateData(); + return render_template("main.html", books = data, attributes = attributes) + if __name__ == "__main__": app.run(debug=True, host='0.0.0.0')