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

47
templates/all.html

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

Loading…
Cancel
Save