|
@ -5,6 +5,7 @@ import json |
|
|
import os |
|
|
import os |
|
|
from time import gmtime, strftime |
|
|
from time import gmtime, strftime |
|
|
from pprint import pprint |
|
|
from pprint import pprint |
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates") |
|
|
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates") |
|
@ -81,7 +82,7 @@ def all(): |
|
|
# print(dict) |
|
|
# print(dict) |
|
|
counter2=0 |
|
|
counter2=0 |
|
|
return render_template('all.html', file=thefile, listingfiles=listingfiles, jsonfiles=jsonfiles, listofdicts=listofdicts, counter2=counter2) |
|
|
return render_template('all.html', file=thefile, listingfiles=listingfiles, jsonfiles=jsonfiles, listofdicts=listofdicts, counter2=counter2) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/description') |
|
|
@app.route('/description') |
|
|
def description(): |
|
|
def description(): |
|
@ -93,40 +94,24 @@ def description(): |
|
|
|
|
|
|
|
|
for file in datafromjson: |
|
|
for file in datafromjson: |
|
|
|
|
|
|
|
|
# # assigning html tag on the basis of extension, to be finished when all the files have been sent |
|
|
|
|
|
# if file.lower().endswith(('.png', '.jpg', '.jpeg')): |
|
|
|
|
|
# file = Markup('<img src="'+file[7:]+'" /> <br />') |
|
|
|
|
|
|
|
|
|
|
|
# #if sound |
|
|
|
|
|
# elif file.lower().endswith(('.mp3')): |
|
|
|
|
|
# file = Markup('''<audio controls> |
|
|
|
|
|
# <source src="'''+file+'''" type="audio/mpeg"> |
|
|
|
|
|
# Your browser does not support the audio tag. |
|
|
|
|
|
# </audio>''') |
|
|
|
|
|
#if txtfile |
|
|
|
|
|
# if file.lower().endswith(('.txt')): |
|
|
|
|
|
# # print(thefile) |
|
|
|
|
|
# with open("static/"+file,"r") as f: |
|
|
|
|
|
# textfile = f.readlines() |
|
|
|
|
|
|
|
|
|
|
|
if file.lower().endswith(('.html')): |
|
|
if file.lower().endswith(('.html')): |
|
|
# print(thefile) |
|
|
|
|
|
with open("static/"+file,"r", encoding='utf-8') as f: |
|
|
with open("static/"+file,"r", encoding='utf-8') as f: |
|
|
textfile = f.read() |
|
|
textfile = f.read() |
|
|
textfile = Markup(textfile) |
|
|
word = "way" |
|
|
|
|
|
wordlinked = "<a href='/diverge?search="+word+"'>"+word+"</a>" |
|
|
|
|
|
textfile = re.sub(word, wordlinked, textfile) |
|
|
|
|
|
|
|
|
# #ifvid to be added |
|
|
|
|
|
# elif file.lower().endswith(('.mp4')): |
|
|
|
|
|
# file = Markup(''' <video width="320" height="240" controls> |
|
|
|
|
|
# <source src="'''+thefile+'''" type="video/mp4"> |
|
|
|
|
|
# Your browser does not support the video tag. |
|
|
|
|
|
# </video> ''') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# go into the textfile content, find the words, |
|
|
|
|
|
# replace word with <a href="/diverge?search=word">word</a> |
|
|
|
|
|
|
|
|
|
|
|
textfile = Markup(textfile) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfile=textfile) |
|
|
return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfile=textfile) |
|
|
|
|
|
|
|
|
|
|
|
@app.route('/diverge') |
|
|
|
|
|
def diverge(): |
|
|
|
|
|
return render_template('diverge.html') |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
if __name__ == '__main__': |
|
|
app.run(debug=True) |
|
|
app.run(debug=True) |
|
|