|
|
@ -30,7 +30,7 @@ thefile = None #selected file for description |
|
|
|
positioninarray = 8 #counter |
|
|
|
listofdicts=[] #to be able to import and use json content |
|
|
|
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 |
|
|
|
# id = "17" |
|
|
@ -144,6 +144,7 @@ def description(): |
|
|
|
#open json file, list filepaths in array and loop with thefile |
|
|
|
textfile="" |
|
|
|
textfiles=[] |
|
|
|
namefile=[] |
|
|
|
with open("static/"+jsonfilefordescription, 'r') as f: |
|
|
|
data_dict = json.load(f) |
|
|
|
datafromjson = data_dict["files"] |
|
|
@ -157,11 +158,12 @@ def description(): |
|
|
|
session["id"] = list(ids) # ... and therefore, we have to convert it back |
|
|
|
for file in datafromjson: |
|
|
|
if file.lower().endswith(('.html')): |
|
|
|
namefile.append(file) |
|
|
|
with open("static/"+file,"r", encoding='utf-8') as f: |
|
|
|
textfile = f.read() |
|
|
|
textfile = Markup(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']) |
|
|
|
def diverge(): |
|
|
@ -206,11 +208,16 @@ def get_file(): |
|
|
|
timelist = session["clicktime"] |
|
|
|
veryfirstnow = session['veryfirstnow'] |
|
|
|
clickongetfiletime = datetime.now() |
|
|
|
|
|
|
|
|
|
|
|
tadam = 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): |
|
|
|
thetime = timelist[0] |
|
|
|
thetime = str(thetime) |
|
|
@ -223,7 +230,12 @@ def get_file(): |
|
|
|
initialtime = "."*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 = [] |
|
|
|
for t in timelist : |
|
|
|
t = str(t) |
|
|
@ -239,7 +251,7 @@ def get_file(): |
|
|
|
print(timelistforoperations) |
|
|
|
print(idlist) |
|
|
|
|
|
|
|
|
|
|
|
# WEAVING DELAYS AND WORDS TOGETHER AS A HUGE STRING OF CHARACTERS |
|
|
|
for (word, time) in zip(wordpath,timelistforoperations): |
|
|
|
# for (word, time, uniqueid) in zip(wordpath,timelistforoperations, idlist): |
|
|
|
# print("word : "+word+"\n") |
|
|
@ -303,7 +315,7 @@ def get_file(): |
|
|
|
# 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) |
|
|
|
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 |
|
|
|
if tadam is None: |
|
|
|