individual links to books are IDs from the csv file, main page is now author ant title
This commit is contained in:
parent
64b13c2023
commit
fc1b8d7045
@ -16,9 +16,12 @@ def getpublications():
|
|||||||
with libcsv:
|
with libcsv:
|
||||||
csv_as_dict = csv.DictReader(libcsv)
|
csv_as_dict = csv.DictReader(libcsv)
|
||||||
listofbooks = []
|
listofbooks = []
|
||||||
|
listofids = []
|
||||||
for row in csv_as_dict:
|
for row in csv_as_dict:
|
||||||
listofbooks.append(row["Publication"])
|
book = "{} - {}".format(row["Author"], row["Publication"])
|
||||||
return listofbooks
|
listofbooks.append(book)
|
||||||
|
listofids.append(row["Id"])
|
||||||
|
return listofids, listofbooks
|
||||||
|
|
||||||
|
|
||||||
parsecsv()
|
parsecsv()
|
||||||
|
@ -13,8 +13,8 @@ APP = flask.Flask(__name__, static_folder="static")
|
|||||||
def index():
|
def index():
|
||||||
"""Main path"""
|
"""Main path"""
|
||||||
# parse csv, render template with a few elements from the csv
|
# parse csv, render template with a few elements from the csv
|
||||||
titles = getpublications()
|
ids, titles = getpublications()
|
||||||
return render_template("index.html", titles=titles)
|
return render_template("index.html", publications=zip(ids, titles))
|
||||||
|
|
||||||
|
|
||||||
@APP.route("/<publication>")
|
@APP.route("/<publication>")
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
<ul>
|
||||||
{% for titles in titles %}
|
{% for id, title in publications %}
|
||||||
<a href="{{ titles }}">{{ titles }}</a>
|
<li><a href="{{ id }}">{{ title }}</a></li>
|
||||||
{% endfor%}
|
{% endfor%}
|
||||||
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user