30 lines
775 B
Python
30 lines
775 B
Python
#!/usr/bin/env python3
|
|
|
|
from xml.etree import ElementTree
|
|
import zipfile
|
|
from flask import Flask, render_template
|
|
app = Flask(__name__)
|
|
|
|
@app.route("/")
|
|
def main():
|
|
out = []
|
|
data = ["title",
|
|
"authors",
|
|
"isbn"]
|
|
|
|
f = zipfile.ZipFile("library.tc")
|
|
tree = ElementTree.parse(f.open("tellico.xml"))
|
|
collection = tree.getroot()[0]
|
|
ns = "{http://periapsis.org/tellico/}"
|
|
|
|
for book in collection.iter(ns + "entry"):
|
|
bookout = {}
|
|
for datum in data:
|
|
d = book.find(ns + datum)
|
|
bookout[datum] = d.text if (d != None) else ""
|
|
out.append(bookout.copy())
|
|
return render_template("books.html", books = out, data = data)
|
|
|
|
if __name__ == "__main__":
|
|
app.run(debug=True, host='0.0.0.0')
|