regex link fine
This commit is contained in:
parent
ad9a518495
commit
0795636bd2
Binary file not shown.
@ -5,6 +5,7 @@ import json
|
||||
import os
|
||||
from time import gmtime, strftime
|
||||
from pprint import pprint
|
||||
import re
|
||||
|
||||
|
||||
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates")
|
||||
@ -81,7 +82,7 @@ def all():
|
||||
# print(dict)
|
||||
counter2=0
|
||||
return render_template('all.html', file=thefile, listingfiles=listingfiles, jsonfiles=jsonfiles, listofdicts=listofdicts, counter2=counter2)
|
||||
|
||||
|
||||
|
||||
@app.route('/description')
|
||||
def description():
|
||||
@ -93,40 +94,24 @@ def description():
|
||||
|
||||
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')):
|
||||
# print(thefile)
|
||||
with open("static/"+file,"r", encoding='utf-8') as f:
|
||||
textfile = f.read()
|
||||
word = "way"
|
||||
wordlinked = "<a href='/diverge?search="+word+"'>"+word+"</a>"
|
||||
textfile = re.sub(word, wordlinked, textfile)
|
||||
|
||||
|
||||
# go into the textfile content, find the words,
|
||||
# replace word with <a href="/diverge?search=word">word</a>
|
||||
|
||||
textfile = Markup(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> ''')
|
||||
|
||||
|
||||
|
||||
return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfile=textfile)
|
||||
|
||||
@app.route('/diverge')
|
||||
def diverge():
|
||||
return render_template('diverge.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
app.run(debug=True)
|
||||
|
@ -15,13 +15,13 @@
|
||||
<div>
|
||||
<img class="img-responsive" src=" ../{{ item }}">
|
||||
</div>
|
||||
|
||||
|
||||
{% elif item.lower().endswith(('.mp4')) %}
|
||||
<div><video width="320" height="240" controls><source src="../{{ item }}" type="video/mp4">
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
</div>
|
||||
|
||||
|
||||
{% elif item.lower().endswith(('.mp3')) %}
|
||||
<div><audio controls><source src="../{{ item }}" type="audio/mpeg">
|
||||
Your browser does not support the audio tag.
|
||||
@ -32,7 +32,7 @@
|
||||
{% endfor %}
|
||||
|
||||
{% if textfile is defined %}
|
||||
<pre>{{ textfile }}</pr>e
|
||||
<pre>{{ textfile }}</pre>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user