move data parsing to its own function

This commit is contained in:
Adam Goldsmith 2015-08-08 19:26:24 -04:00
parent 2228672a16
commit f00fe1e54a
1 changed files with 14 additions and 7 deletions

21
test.py
View File

@ -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')