move data parsing to its own function
This commit is contained in:
parent
2228672a16
commit
f00fe1e54a
21
test.py
21
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')
|
||||
|
Loading…
Reference in New Issue
Block a user