the score works finely
This commit is contained in:
parent
6b6f110019
commit
f469963470
Binary file not shown.
@ -112,9 +112,10 @@ def functionsession():
|
||||
return(session)
|
||||
|
||||
# THIS IS NOT WORKING YET DUNNO WHY
|
||||
# @app.context_processor
|
||||
# def context_processor():
|
||||
# return dict(functionsession=functionsession)
|
||||
@app.context_processor
|
||||
def context_processor():
|
||||
functionsession = session['wordpath']
|
||||
return dict(functionsession=functionsession)
|
||||
|
||||
@app.route('/about/')
|
||||
def about():
|
||||
@ -182,7 +183,21 @@ def get_file():
|
||||
idlist = session["id"]
|
||||
timelist = session["clicktime"]
|
||||
veryfirstnow = session['veryfirstnow']
|
||||
clickongetfiletime = datetime.now()
|
||||
|
||||
tadam = None
|
||||
initialtime = None
|
||||
|
||||
if not (timelist[0] is None):
|
||||
thetime = timelist[0]
|
||||
thetime = str(thetime)
|
||||
thetime = dt.datetime.strptime(thetime, '%Y-%m-%d %H:%M:%S.%f')
|
||||
initialtime = thetime - veryfirstnow
|
||||
initialtime = initialtime.total_seconds()
|
||||
initialtime = int(initialtime)
|
||||
initialtime = "."*initialtime
|
||||
|
||||
print(initialtime)
|
||||
|
||||
for t in timelist :
|
||||
t = str(t)
|
||||
@ -192,7 +207,16 @@ def get_file():
|
||||
prev = None
|
||||
wholestringy = None
|
||||
|
||||
print("veryfirstnow : "+str(veryfirstnow)+"\n")
|
||||
|
||||
|
||||
|
||||
for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist):
|
||||
print("word : "+word+"\n")
|
||||
print("timeofclick : "+str(time)+"\n")
|
||||
print("============")
|
||||
print(wordpath)
|
||||
print("============")
|
||||
filler = int(uniqueid)
|
||||
upperword = word.upper()
|
||||
|
||||
@ -225,18 +249,41 @@ def get_file():
|
||||
fullscore = wholestringy
|
||||
|
||||
|
||||
#If fullscore length superior 60 characters, insert linebreak
|
||||
# #If fullscore length superior 60 characters, insert linebreak
|
||||
|
||||
# # Defining splitting point
|
||||
# n = 60
|
||||
# # Using list comprehension
|
||||
# out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)]
|
||||
# #joining the strings with linebreaks
|
||||
# tadam = '\n'.join(out)
|
||||
|
||||
|
||||
if not (fullscore is None):
|
||||
# outside of the loop calculate seconds from "clickongetfiletime" minus the last "time" from the loop
|
||||
lastdifftime = clickongetfiletime - prev
|
||||
lastdifftime = lastdifftime.total_seconds()
|
||||
lastdifftime = int(lastdifftime)
|
||||
lastdifftime = lastdifftime * '.'
|
||||
#the 60 seconds thing
|
||||
# print(lastdifftime+"\n")
|
||||
fullscore = initialtime+fullscore+lastdifftime
|
||||
# Defining splitting point
|
||||
n = 60
|
||||
# Using list comprehension
|
||||
out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)]
|
||||
#joining the strings with linebreaks
|
||||
tadam = '\n'.join(out)
|
||||
|
||||
|
||||
|
||||
# have a message in file if no nav has been recorded so it's less dull than error page
|
||||
if tadam is None:
|
||||
tadam = "This score is Null"
|
||||
|
||||
# print("verylastnow : "+str(clickongetfilefime)+"\n")
|
||||
|
||||
|
||||
print(tadam)
|
||||
|
||||
return Response(tadam,
|
||||
|
@ -4,16 +4,17 @@ import re
|
||||
|
||||
with open('wordlist.json', 'r') as f:
|
||||
wordlist_dict = json.load(f)
|
||||
|
||||
#goes through every single file ending in html
|
||||
#
|
||||
path = "static/files/"
|
||||
for path, subdirs, files in os.walk(path):
|
||||
for name in files:
|
||||
if name.endswith('html'):
|
||||
file = os.path.join(path, name)
|
||||
with open(file, 'r+') as f:
|
||||
with open(file, 'r+', encoding="utf-8") as f:
|
||||
textfile = f.read()
|
||||
for word in wordlist_dict:
|
||||
# word = re.escape(word)
|
||||
word = re.escape(word)
|
||||
textfile = re.sub(r"(?<!<)(?<!</)(?<!ge\?)\b(%s)\b" %word, r"<a href='/diverge?search=\1'>\1</a>", textfile)
|
||||
f.truncate(0)
|
||||
f.write(textfile)
|
||||
|
@ -26,6 +26,9 @@
|
||||
</nav></strong>
|
||||
</div>
|
||||
</header>
|
||||
<div>
|
||||
{{ functionsession }}
|
||||
</div>
|
||||
<div class="container">
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
|
Loading…
Reference in New Issue
Block a user