csv-library-website/library/page.py

52 lines
1.2 KiB
Python
Raw Normal View History

"""This is the main flask library page"""
import flask
from flask import render_template
from csvparser.csvparser import (
getlicenses,
getpublications,
gettypes,
getyears,
getfullpublication,
)
APP = flask.Flask(__name__, static_folder="static")
@APP.route("/")
def index():
"""Main route, shows all the books and you can filter them, a bit"""
pubtypes = gettypes()
2020-12-21 18:58:46 +01:00
pubyears = getyears()
publicenses = getlicenses()
publicatons = getpublications()
2020-12-21 18:58:46 +01:00
template = render_template(
"index.html",
publications=publicatons,
pubtypes=pubtypes,
pubyears=pubyears,
publicenses=publicenses,
2020-12-21 18:58:46 +01:00
)
return template
@APP.route("/<publicationID>")
def show_book(publicationID):
"""route for a publication, still needs to be made"""
fullpublication = getfullpublication(publicationID)
# parse csv, render template with full list.
return render_template("publication.html", fullpublication=fullpublication)
@APP.route("/<publication>")
def upload_book(publication):
"""upload a new book, still needs to be made"""
return render_template("upload.html")
if __name__ == "__main__":
APP.debug = True
APP.run(port=5000)