move data parsing to its own function
This commit is contained in:
parent
2228672a16
commit
f00fe1e54a
19
test.py
19
test.py
@ -5,12 +5,13 @@ import zipfile
|
|||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route("/")
|
data = []
|
||||||
def main():
|
attributes= ["title",
|
||||||
|
"authors",
|
||||||
|
"isbn"]
|
||||||
|
|
||||||
|
def updateData():
|
||||||
out = []
|
out = []
|
||||||
data = ["title",
|
|
||||||
"authors",
|
|
||||||
"isbn"]
|
|
||||||
|
|
||||||
f = zipfile.ZipFile("library.tc")
|
f = zipfile.ZipFile("library.tc")
|
||||||
tree = ElementTree.parse(f.open("tellico.xml"))
|
tree = ElementTree.parse(f.open("tellico.xml"))
|
||||||
@ -28,7 +29,13 @@ def main():
|
|||||||
bookout["authors"] = "; ".join(authors)
|
bookout["authors"] = "; ".join(authors)
|
||||||
|
|
||||||
out.append(bookout.copy())
|
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__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True, host='0.0.0.0')
|
app.run(debug=True, host='0.0.0.0')
|
||||||
|
Loading…
Reference in New Issue
Block a user