This is a reusable plain version the varia library website. You can host your own website of books using just a simple csv file
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
"""This is the main flask page code"""
|
|
|
|
|
|
|
|
|
|
|
|
import flask
|
|
|
|
from flask import render_template
|
|
|
|
|
|
|
|
from library.csvparser.csvparser import getpublications
|
|
|
|
|
|
|
|
APP = flask.Flask(__name__, static_folder="static")
|
|
|
|
|
|
|
|
|
|
|
|
@APP.route("/")
|
|
|
|
def index():
|
|
|
|
"""Main path"""
|
|
|
|
# parse csv, render template with a few elements from the csv
|
|
|
|
ids, titles = getpublications()
|
|
|
|
return render_template("index.html", publications=zip(ids, titles))
|
|
|
|
|
|
|
|
|
|
|
|
@APP.route("/<publication>")
|
|
|
|
def show_book(publication):
|
|
|
|
"""Path for a publication"""
|
|
|
|
# parse csv, render template with full list.
|
|
|
|
return render_template("publication.html", publication=publication)
|
|
|
|
|
|
|
|
|
|
|
|
@APP.route("/<publication>")
|
|
|
|
def upload_book(publication):
|
|
|
|
"""upload a new book"""
|
|
|
|
#
|
|
|
|
return render_template("upload form")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
APP.debug = True
|
|
|
|
APP.run(port=5000)
|