|
@ -30,7 +30,7 @@ thefile = None #selected file for description |
|
|
positioninarray = 8 #counter |
|
|
positioninarray = 8 #counter |
|
|
listofdicts=[] #to be able to import and use json content |
|
|
listofdicts=[] #to be able to import and use json content |
|
|
datafromjson = [] |
|
|
datafromjson = [] |
|
|
max_wordpath_items = 200 # limit the nr. of items, as to |
|
|
max_wordpath_items = 500 # limit the nr. of items, as to prevent possible glitches with bots |
|
|
|
|
|
|
|
|
# #test getting json file from id |
|
|
# #test getting json file from id |
|
|
# id = "17" |
|
|
# id = "17" |
|
@ -144,6 +144,7 @@ def description(): |
|
|
#open json file, list filepaths in array and loop with thefile |
|
|
#open json file, list filepaths in array and loop with thefile |
|
|
textfile="" |
|
|
textfile="" |
|
|
textfiles=[] |
|
|
textfiles=[] |
|
|
|
|
|
namefile=[] |
|
|
with open("static/"+jsonfilefordescription, 'r') as f: |
|
|
with open("static/"+jsonfilefordescription, 'r') as f: |
|
|
data_dict = json.load(f) |
|
|
data_dict = json.load(f) |
|
|
datafromjson = data_dict["files"] |
|
|
datafromjson = data_dict["files"] |
|
@ -157,11 +158,12 @@ def description(): |
|
|
session["id"] = list(ids) # ... and therefore, we have to convert it back |
|
|
session["id"] = list(ids) # ... and therefore, we have to convert it back |
|
|
for file in datafromjson: |
|
|
for file in datafromjson: |
|
|
if file.lower().endswith(('.html')): |
|
|
if file.lower().endswith(('.html')): |
|
|
|
|
|
namefile.append(file) |
|
|
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) |
|
|
textfile = Markup(textfile) |
|
|
textfiles.append(textfile) |
|
|
textfiles.append(textfile) |
|
|
return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfiles=textfiles, idno=idno, index_dict=index_dict) |
|
|
return render_template('description.html', datafromjson=datafromjson, itemid=itemid, textfiles=textfiles, idno=idno, index_dict=index_dict, namefile=namefile) |
|
|
|
|
|
|
|
|
@app.route('/diverge', methods=['GET']) |
|
|
@app.route('/diverge', methods=['GET']) |
|
|
def diverge(): |
|
|
def diverge(): |
|
@ -206,11 +208,16 @@ def get_file(): |
|
|
timelist = session["clicktime"] |
|
|
timelist = session["clicktime"] |
|
|
veryfirstnow = session['veryfirstnow'] |
|
|
veryfirstnow = session['veryfirstnow'] |
|
|
clickongetfiletime = datetime.now() |
|
|
clickongetfiletime = datetime.now() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tadam = None |
|
|
tadam = None |
|
|
initialtime = None |
|
|
initialtime = None |
|
|
|
|
|
|
|
|
|
|
|
# USER IP ADDRESS OBTENTION |
|
|
|
|
|
if request.environ.get('HTTP_X_FORWARDED_FOR') is None: |
|
|
|
|
|
userip = request.environ['REMOTE_ADDR'] |
|
|
|
|
|
else: |
|
|
|
|
|
userip = request.environ['HTTP_X_FORWARDED_FOR'] # if behind a proxy |
|
|
|
|
|
|
|
|
|
|
|
# CALCULATION OF INITIAL TIME BEFORE FIRST CLICK |
|
|
if len(timelist) and not (timelist[0] is None): |
|
|
if len(timelist) and not (timelist[0] is None): |
|
|
thetime = timelist[0] |
|
|
thetime = timelist[0] |
|
|
thetime = str(thetime) |
|
|
thetime = str(thetime) |
|
@ -223,7 +230,12 @@ def get_file(): |
|
|
initialtime = "."*initialtime |
|
|
initialtime = "."*initialtime |
|
|
|
|
|
|
|
|
print(initialtime) |
|
|
print(initialtime) |
|
|
|
|
|
#CALCULATE FILE NUMBER |
|
|
|
|
|
|
|
|
|
|
|
dirListing = os.listdir("scores/") |
|
|
|
|
|
scorenumber = len(dirListing) |
|
|
|
|
|
|
|
|
|
|
|
# CONVERSION OF TIME INTO FORMATS THAT CAN BE USED FOR CALCULATIONS |
|
|
timelistforoperations = [] |
|
|
timelistforoperations = [] |
|
|
for t in timelist : |
|
|
for t in timelist : |
|
|
t = str(t) |
|
|
t = str(t) |
|
@ -239,7 +251,7 @@ def get_file(): |
|
|
print(timelistforoperations) |
|
|
print(timelistforoperations) |
|
|
print(idlist) |
|
|
print(idlist) |
|
|
|
|
|
|
|
|
|
|
|
# WEAVING DELAYS AND WORDS TOGETHER AS A HUGE STRING OF CHARACTERS |
|
|
for (word, time) in zip(wordpath,timelistforoperations): |
|
|
for (word, time) in zip(wordpath,timelistforoperations): |
|
|
# for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist): |
|
|
# for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist): |
|
|
# print("word : "+word+"\n") |
|
|
# print("word : "+word+"\n") |
|
@ -303,7 +315,7 @@ def get_file(): |
|
|
# Using list comprehension |
|
|
# Using list comprehension |
|
|
out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)] |
|
|
out = [(fullscore[i:i+n]) for i in range(0, len(fullscore), n)] |
|
|
#joining the strings with linebreaks |
|
|
#joining the strings with linebreaks |
|
|
tadam = '\n'.join(out) |
|
|
tadam = '\n'.join(out) +"\n\nScore number : "+str(scorenumber)+ "\nGenerated at : "+str(clickongetfiletime)+"\nBy author : "+ userip |
|
|
|
|
|
|
|
|
# have a message in file if no nav has been recorded so it's less dull than error page |
|
|
# have a message in file if no nav has been recorded so it's less dull than error page |
|
|
if tadam is None: |
|
|
if tadam is None: |
|
|