Browse Source

fixed some things

master
Cristina Cochior 6 years ago
parent
commit
6aa350404a
  1. 11
      contextualise.py
  2. 2
      static/files/001/2019-01-22_08:49:43_data_file.json
  3. 2
      static/files/002/2019-01-20_17:47:03_data_file.json
  4. 2
      static/files/002/2019-01-22_09:09:09_data_file.json
  5. BIN
      static/files/003/.DS_Store
  6. 1
      static/files/003/2019-01-22_09:09:52_data_file.json
  7. 1
      static/files/003/2019-01-23_10:38:26_data_file.json
  8. 43
      templates/all.html

11
contextualise.py

@ -12,6 +12,7 @@ from pprint import pprint
app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates")
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
app.config.from_object(Config)
@ -38,7 +39,7 @@ for path, subdirs, files in os.walk(path):
#excluding json files from listing :-)
if not name.endswith(".json") and not name.endswith(".DS_Store"):
fullpath = os.path.join(path, name)
listingdirectories.append(path[7:])
listingdirectories.append(path)
listingfiles.append(fullpath[7:]) #fullpaths minus static/
# print (path)
# print (name)
@ -67,9 +68,9 @@ def about():
def all():
thefile = listingfiles[positioninarray]
print(listingfiles)
#here i need to json.load each file
print(dict)
return render_template('all.html', file=thefile, listingfiles=listingfiles, jsonfiles=jsonfiles, listofdicts=listofdicts)
# print(dict)
counter2=0
return render_template('all.html', file=thefile, listingfiles=listingfiles, jsonfiles=jsonfiles, listofdicts=listofdicts, counter2=counter2)
@app.route('/description', methods=['GET', 'POST'])
@ -105,7 +106,7 @@ def description():
@app.route('/get-data', methods=['GET', 'POST'])
def savepost():
if request.method=='POST':
dict={'name':request.form['name'],'email':request.form['email'],'friend':request.form['friend'],'content':request.form['content']}
dict={'id':listingdirectories[positioninarray][13:],'name':request.form['name'],'email':request.form['email'],'friend':request.form['friend'],'content':request.form['content']}
# open with "a" if the file should concatenate content
#json file naming gone unique by adding time and date of submission

2
static/files/001/2019-01-22_08:49:43_data_file.json

@ -1 +1 @@
{"name": "Canonimouse", "email": "yes@mail.com", "friend": "Y", "content": "The contestants are embracing."}
{"id":"001","name": "Canonimouse", "email": "yes@mail.com", "friend": "Y", "content": "The contestants are embracing."}

2
static/files/002/2019-01-20_17:47:03_data_file.json

@ -1 +1 @@
{"name": "Cristina Cochior", "email": "clcochior@gmail.com", "friend": "Y", "content": "Sure"}
{"id":"002","name": "XYZ", "email": "yesihave@one.com", "friend": "Y", "content": "Sure"}

2
static/files/002/2019-01-22_09:09:09_data_file.json

@ -1 +1 @@
{"name": "Anonymousse", "email": "bettermail@mail.com", "friend": "Y", "content": "A beach in an Arab-speaking place."}
{"id":"002","name": "Anonymousse", "email": "bettermail@mail.com", "friend": "Y", "content": "A beach in an Arab-speaking place."}

BIN
static/files/003/.DS_Store

Binary file not shown.

1
static/files/003/2019-01-22_09:09:52_data_file.json

@ -1 +0,0 @@
{"name": "Mysterious", "email": "sound@mail.com", "friend": "Y", "content": "This is a sound file, but I am in a public setting and cannot listen back to it."}

1
static/files/003/2019-01-23_10:38:26_data_file.json

@ -0,0 +1 @@
{"id": "003", "name": "Yes", "email": "sure@whynot.com", "friend": "Y", "content": "A sound file."}

43
templates/all.html

@ -3,23 +3,26 @@
{% block content %}
<div class="all">
<h1>These are all the files</h1>
<!-- {{ listingfiles }} <br>
{{ listingfiles }} <br>
{{ jsonfiles }} <br>
{{ listingdirectories }} -->
{{ listofdicts }} <br>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
{% for filename in listingfiles %}
{% if filename.lower().endswith(('.png', '.jpg', '.jpeg')) %}
<img class="img-responsive" src=" ../{{ filename }}">
{% for jsonfile in jsonfiles %}
{% if filename[0:9] == jsonfile[0:9] %}
<div class="descrip">
{{ jsonfile }}
<p>{{listofdicts[0]["name"]}}<br>
{{listofdicts[0]["email"]}}<br>
{{listofdicts[0]["friend"]}}<br>
{{listofdicts[0]["content"]}}</p>
{% for dict in listofdicts %}
{% if jsonfile[6:9]==dict["id"] %}
<p>{% for key, value in dict.items() %}
{{key}}: {{value}}<br>
{% endfor %}</p>
{% endif %}
{% endfor %}
</div>
{% break %}
{% endif %}
{% endfor %}
@ -31,11 +34,15 @@
{% if filename[0:9] == jsonfile[0:9] %}
<div class="descrip">
{{ jsonfile }}
<p>{{listofdicts[1]["name"]}}<br>
{{listofdicts[1]["email"]}}<br>
{{listofdicts[1]["friend"]}}<br>
{{listofdicts[1]["content"]}}</p>
{% for dict in listofdicts %}
{% if jsonfile[6:9]==dict["id"] %}
<p>{% for key, value in dict.items() %}
{{key}}: {{value}}<br>
{% endfor %}</p>
{% endif %}
{% endfor %}
</div>
{% break %}
{% endif %}
{% endfor %}
@ -44,14 +51,18 @@
Your browser does not support the audio tag.
</audio>
{% for jsonfile in jsonfiles %}
{% if filename[0:9] == jsonfile[0:9] %}
{% if filename[0:9] == jsonfile[0:9]%}
<div class="descrip">
{{ jsonfile }}
<p>{{listofdicts[2]["name"]}}<br>
{{listofdicts[2]["email"]}}<br>
{{listofdicts[2]["friend"]}}<br>
{{listofdicts[2]["content"]}}</p>
{% for dict in listofdicts %}
{% if jsonfile[6:9]==dict["id"] %}
<p>{% for key, value in dict.items() %}
{{key}}: {{value}}<br>
{% endfor %}</p>
{% endif %}
{% endfor %}
</div>
{% break %}
{% endif %}
{% endfor %}
{% endif %}

Loading…
Cancel
Save