cookie page
This commit is contained in:
parent
d58346e7f4
commit
798d1adcf4
Binary file not shown.
@ -1,5 +1,4 @@
|
||||
from flask import Flask, url_for, render_template, Markup, redirect, request, flash
|
||||
from flask import session as login_session
|
||||
from flask import Flask, url_for, render_template, Markup, redirect, request, flash, session, make_response
|
||||
from config import Config
|
||||
import json
|
||||
import os
|
||||
@ -12,6 +11,8 @@ app = Flask(__name__, static_url_path='', static_folder="static", template_folde
|
||||
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
|
||||
app.config.from_object(Config)
|
||||
|
||||
#############cookie stuff
|
||||
# app.secret_key = os.urandom(24)
|
||||
|
||||
# setting variables for holding paths, folder names and the one file for description
|
||||
path = "static/files/"
|
||||
@ -25,7 +26,6 @@ positioninarray = 8 #counter
|
||||
listofdicts=[] #to be able to import and use json content
|
||||
datafromjson = []
|
||||
|
||||
|
||||
#test getting json file from id
|
||||
id = "17"
|
||||
jsonfilefordescription = "files/"+id+"/"+id+".json"
|
||||
@ -34,11 +34,6 @@ jsonfilefordescription = "files/"+id+"/"+id+".json"
|
||||
pathofwords = []
|
||||
pathofnumbers = []
|
||||
|
||||
#reading wordlist.json
|
||||
with open('wordlist.json', 'r') as f:
|
||||
wordlist_dict = json.load(f)
|
||||
|
||||
|
||||
#listing paths and files, not in order but well...
|
||||
for path, subdirs, files in os.walk(path):
|
||||
for name in files:
|
||||
@ -71,14 +66,17 @@ print("-------------------------")
|
||||
dict = {} #dict for the form entries
|
||||
|
||||
|
||||
with open("static/"+jsonfilefordescription, 'r') as f:
|
||||
with open("static/"+jsonfiles[4], 'r') as f:
|
||||
data_dict = json.load(f)
|
||||
datafromjson = data_dict["files"]
|
||||
print(datafromjson)
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return render_template('home.html')
|
||||
words = ["way", "blablabla", "uqhdiuqsiud"]
|
||||
res = make_response(render_template('home.html'))
|
||||
res.set_cookie("qhdqhd",str(words) , max_age=60*60*24*365*2)
|
||||
return res
|
||||
|
||||
@app.route('/about/')
|
||||
def about():
|
||||
@ -92,7 +90,6 @@ def all():
|
||||
counter2=0
|
||||
return render_template('all.html', file=thefile, listingfiles=listingfiles, jsonfiles=jsonfiles, listofdicts=listofdicts, counter2=counter2)
|
||||
|
||||
|
||||
@app.route('/description')
|
||||
def description():
|
||||
#open json file, list filepaths in array and loop with thefile
|
||||
@ -116,7 +113,11 @@ def description():
|
||||
@app.route('/diverge', methods=['GET'])
|
||||
def diverge():
|
||||
searchterm=request.args.get('search')
|
||||
return render_template('diverge.html', wordlist_dict=wordlist_dict, searchterm=searchterm)
|
||||
return render_template('diverge.html', searchterm=searchterm)
|
||||
|
||||
@app.route('/listofwords')
|
||||
def listofwords():
|
||||
return render_template('listofwords.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
|
@ -15,6 +15,7 @@
|
||||
<li><a href="{{ url_for('about') }}">About</a></li>
|
||||
<li><a href="{{ url_for('description') }}">Description</a></li>
|
||||
<li><a href="{{ url_for('all') }}">All files</a></li>
|
||||
<li><a href="{{ url_for('listofwords') }}">List of words</a></li>
|
||||
</ul>
|
||||
</nav></strong>
|
||||
</div>
|
||||
@ -24,4 +25,4 @@
|
||||
{% endblock %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
3
templates/listofwords.html
Normal file
3
templates/listofwords.html
Normal file
@ -0,0 +1,3 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block content %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user