initial commit
This commit is contained in:
commit
1a085b68c5
16
templates/books.html
Normal file
16
templates/books.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<title>Test App</title>
|
||||
<table border="1" style="white-space:nowrap;">
|
||||
<tr>
|
||||
{% for datum in data %}
|
||||
<th> {{ datum }} </th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% for book in books %}
|
||||
<tr>
|
||||
{% for datum in data %}
|
||||
<td> {{ book[datum] }} </td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
29
test.py
Normal file
29
test.py
Normal file
@ -0,0 +1,29 @@
|
||||
#!/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')
|
Loading…
Reference in New Issue
Block a user