Project for the Hybrid Publishing thesis award of 2018.
By Julie Boschat Thorez and Cristina Cochior.
https://www.wdka.nl/work/sic-scripture
http://51.255.169.99:8080/
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.
80 lines
3.4 KiB
80 lines
3.4 KiB
4 years ago
|
from flask import Flask, render_template, Markup, jsonify
|
||
|
import json
|
||
|
import os
|
||
|
from json import dumps
|
||
|
from flask import request # new
|
||
|
|
||
|
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates")
|
||
|
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
|
||
|
|
||
|
|
||
|
# SETTING THE VARIABLES
|
||
|
path = "/static/files/"
|
||
|
|
||
|
#move this list to Jinja so it can be placed in layout
|
||
|
#give back clicked value
|
||
|
# librarians = ["Alana", "Gentian", "Laurie", "Matias", "Scott", "Stacy", "Max", "Clara_B", "Michelle", "Clara_J_B", "Karen", "Lumsden_Primary_School", "Aaron", "Leo", "Maria", "Laura", "Honey", "Tender_Center", "wdka", "Naomi", "Cristina", "Julie", "ssw", "cyberspace", "Hannah", "Katarina", "Anastasia", "Kimmy", "Marie","Katherine", "Allison", "Mariana", "Viki", "Alice", "Eric", "hks", "cbk", "Sophie", "Antonio", "Jeremiah", "Angela", "Renee", "Marta", "Katherine", "Anna", "Auryn", "Ashley", "Anne", "Denise", "Eva", "Jonnah", "Kitty", "Masha", "Mia", "Cian", "Senke", "Maud", "Jinnie", "Rubin", "Julia", "Alana", "Gentian", "Laurie", "Matias","Scott", "Stacy"]
|
||
|
|
||
|
librarians = []
|
||
|
files_without_folders = []
|
||
|
|
||
|
with open('static/js/mergedjson.json', 'r', encoding='utf8') as filesandnames:
|
||
|
filetoname_dict = json.load(filesandnames)
|
||
|
|
||
|
#get full list librarians from json (printed later through global variable)
|
||
|
for file in filetoname_dict:
|
||
|
for name in file["librarian"]:
|
||
|
librarians.append(str(name))
|
||
|
librarians = list(dict.fromkeys(librarians))
|
||
|
|
||
|
#this value we should get from template
|
||
|
librarianselected = "Ruben"
|
||
|
|
||
|
#go from librarian name to file
|
||
|
for file in filetoname_dict:
|
||
|
# if librarianselected in file["librarian"]:
|
||
|
thedebris = file["debrisname"]
|
||
|
#apply regex to the debris
|
||
|
thedebris = os.path.basename(thedebris)
|
||
|
files_without_folders.append(str(thedebris))
|
||
|
# print(str(librarianselected)+" contributed with the following debris : "+str(thedebris))
|
||
|
|
||
|
|
||
|
|
||
|
#this value we should get from template
|
||
|
fileselected = filetoname_dict[1]["debrisname"]
|
||
|
|
||
|
#go from file name to librarian name
|
||
|
for file in filetoname_dict:
|
||
|
if fileselected in file["debrisname"]:
|
||
|
thelibrarian = file["librarian"]
|
||
|
print("librarians for "+ str(fileselected)+" are: " + str(thelibrarian))
|
||
|
print("---------------------------------------------------")
|
||
|
|
||
|
print(librarians)
|
||
|
|
||
|
@app.route("/", methods=['POST', 'GET']) # new
|
||
|
def home():
|
||
|
if request.args:
|
||
|
# We have our query string nicely serialized as a Python dictionary
|
||
|
args = request.args
|
||
|
# We'll create a string to display the parameters & values
|
||
|
serialized = ", ".join(f"{k}: {v}" for k, v in request.args.items())
|
||
|
# Display the query string to the client in a different format
|
||
|
# return f"(Query) {serialized}", 200
|
||
|
urllibrarian=request.args.getlist('librarian') # new
|
||
|
urlmethod=request.args.getlist('method') # new
|
||
|
for a in urllibrarian:
|
||
|
print('urllibrarian is: '+ a)
|
||
|
for b in urlmethod:
|
||
|
print('urlmethod is: ' + b)
|
||
|
return render_template('layout.html', urllibrarian=urllibrarian, urlmethod=urlmethod, filetoname_dict=filetoname_dict, librarians=librarians, files_without_folders = files_without_folders) # new
|
||
|
|
||
|
@app.route('/about/')
|
||
|
def about():
|
||
|
return render_template('about.html')
|
||
|
|
||
|
@app.route('/exchange')
|
||
|
def exchange():
|
||
|
return render_template('exchange.html')
|