zeroth
6 years ago
11 changed files with 367 additions and 94 deletions
Binary file not shown.
@ -1 +1,13 @@ |
|||
{"id": "00.", "name": "Yes", "email": "sure@whynot.com", "friend": "Y", "content": "A sound file."} |
|||
{ |
|||
"id": "00.", |
|||
"name": "Yes", |
|||
"email": "sure@whynot.com", |
|||
"friend": "Y", |
|||
"content": "A sound file.", |
|||
"files":[ |
|||
"static/files/00. Pushing Scores/Participants.txt", |
|||
"static/files/00. Pushing Scores/PushingScores.txt", |
|||
"static/files/00. Pushing Scores/events.txt" |
|||
|
|||
] |
|||
} |
@ -1 +1,11 @@ |
|||
{"id": "01.", "name": "Yes", "email": "sure@whynot.com", "friend": "Y", "content": "A sound file."} |
|||
{ |
|||
"id": "01.", |
|||
"name": "Yes", |
|||
"email": "sure@whynot.com", |
|||
"friend": "Y", |
|||
"content": "A sound file.", |
|||
"files": [ |
|||
"static/files/01. Event Tetra Gamma Circulaire 1/01.metadata.txt", |
|||
"static/files/01. Event Tetra Gamma Circulaire 1/Photo/TGC1club-web-06 februari 2015-02.jpg" |
|||
] |
|||
} |
@ -1 +1,16 @@ |
|||
{"id": "02.", "name": "Yes", "email": "sure@whynot.com", "friend": "Y", "content": "A sound file."} |
|||
{ |
|||
"id": "02.", |
|||
"name": "Yes", |
|||
"email": "sure@whynot.com", |
|||
"friend": "Y", |
|||
"content": "A sound file.", |
|||
"files": [ |
|||
"static/files/02. release DOB084 Tetra Gamma Circulaire 3/02.metadata.txt", |
|||
"static/files/02. release DOB084 Tetra Gamma Circulaire 3/Photo/Scan Manual BACK 300dpi.jpg", |
|||
"static/files/02. release DOB084 Tetra Gamma Circulaire 3/Photo/Scan Manual FRONT 300dpi.jpg", |
|||
"static/files/02. release DOB084 Tetra Gamma Circulaire 3/Photo/TGC3achterkant.jpg", |
|||
"static/files/02. release DOB084 Tetra Gamma Circulaire 3/Photo/TGC3.jpg", |
|||
"static/files/02. release DOB084 Tetra Gamma Circulaire 3/Photo/TGC3 top.jpg", |
|||
"static/files/02. release DOB084 Tetra Gamma Circulaire 3/Photo/TGC3voorkant.jpg" |
|||
] |
|||
} |
@ -1 +1,11 @@ |
|||
{"id": "03.", "name": "Yes", "email": "sure@whynot.com", "friend": "Y", "content": "A sound file."} |
|||
{ |
|||
"id": "03.", |
|||
"name": "Yes", |
|||
"email": "sure@whynot.com", |
|||
"friend": "Y", |
|||
"content": "A sound file.", |
|||
"files": [ |
|||
"static/files/03.150702 Kris Principium2 Stadslimiet Antwerpen/03.metadata.txt", |
|||
"static/files/03.150702 Kris Principium2 Stadslimiet Antwerpen/Photo/Kris princ2-s-2000px-72dpi-79 02 juli 2015.jpg" |
|||
] |
|||
} |
@ -1 +1,16 @@ |
|||
{"id": "05.", "name": "Yes", "email": "sure@whynot.com", "friend": "Y", "content": "A sound file."} |
|||
{ |
|||
"id": "05.", |
|||
"name": "Yes", |
|||
"email": "sure@whynot.com", |
|||
"friend": "Y", |
|||
"content": "A sound file.", |
|||
"files": [ |
|||
"static/files/05. 160909 Wiels ArtbookFair Vaast Colson/05.metadata.txt", |
|||
"static/files/05. 160909 Wiels ArtbookFair Vaast Colson/Sound/DOB079_VaastColson_CarlsonInvents.mp3", |
|||
"static/files/05. 160909 Wiels ArtbookFair Vaast Colson/Photo/DOB079-Vaast-Colson-spread-1600px-web-160913-1.jpg", |
|||
"static/files/05. 160909 Wiels ArtbookFair Vaast Colson/Photo/DOB079-Vaast-Colson-1600px-web-160913-11.jpg", |
|||
"static/files/05. 160909 Wiels ArtbookFair Vaast Colson/Photo/ArtBookFairBrussel-Vaast Colson-6d-20160909-57-20.jpg", |
|||
"static/files/05. 160909 Wiels ArtbookFair Vaast Colson/Photo/DOB079-Vaast-Colson-1600px-web-160913-10.jpg", |
|||
"static/files/05. 160909 Wiels ArtbookFair Vaast Colson/Photo/VaastColson.jpg" |
|||
] |
|||
} |
@ -1 +1,12 @@ |
|||
{"id": "17.", "Who": "George Brecht", "What": "Works", "content": "A sound file."} |
|||
{ |
|||
"id": "17.", |
|||
"Who": "George Brecht", |
|||
"What": "Works", |
|||
"content": "A sound file.", |
|||
"files": [ |
|||
"files/17. George Brecht_event scores/17.blurb.txt", |
|||
"files/17. George Brecht_event scores/Photo/brecht-event1.jpg", |
|||
"files/17. George Brecht_event scores/Photo/svc-1966-brecht's sundown event-i.jpg", |
|||
"files/17. George Brecht_event scores/Video/Drip Music - George Brecht (Fluxus)-UT5lgaE-qZY.mkv" |
|||
] |
|||
} |
@ -1,21 +1,40 @@ |
|||
{% extends "layout.html" %} |
|||
{% block content %} |
|||
<div class="description"> |
|||
<h2 style = "text-align: center;">Write something very interesting here.</h2> |
|||
<h2 style = "text-align: center;">{{ itemid }}</h2> |
|||
|
|||
<!--passing files--> |
|||
<p>{{ file }}</p> |
|||
|
|||
<!-- <img src="{{ url_for('static', filename='/files/001/DwySYC4X4AESeRh.jpg') }}"> |
|||
--> |
|||
<!--passing an array--> |
|||
<!-- {% for v in listingdirectories %} |
|||
<div>{{ v }}</div> |
|||
{% endfor %} |
|||
{% for f in listingfiles %} |
|||
<div>{{ f }}</div> |
|||
{% endfor %} |
|||
--> |
|||
<p>{{ datafromjson }}</p> |
|||
|
|||
<div class="col-lg-3 col-md-4 col-xs-6 thumb"> |
|||
|
|||
|
|||
{% for item in datafromjson %} |
|||
|
|||
{% if item.lower().endswith(('.png', '.jpg', '.jpeg')) %} |
|||
<div> |
|||
<img class="img-responsive" src=" ../{{ item }}"> |
|||
</div> |
|||
|
|||
{% elif item.lower().endswith(('.mp4')) %} |
|||
<div><video width="320" height="240" controls><source src="../{{ item }}" type="video/mp4"> |
|||
Your browser does not support the video tag. |
|||
</video> |
|||
</div> |
|||
|
|||
{% elif item.lower().endswith(('.mp3')) %} |
|||
<div><audio controls><source src="../{{ item }}" type="audio/mpeg"> |
|||
Your browser does not support the audio tag. |
|||
</audio> |
|||
</div> |
|||
{% endif %} |
|||
|
|||
{% endfor %} |
|||
|
|||
{% if textfile is defined %} |
|||
<p>{{ textfile }}</p> |
|||
{% endif %} |
|||
|
|||
|
|||
</div> |
|||
{% endblock %} |
|||
|
@ -0,0 +1,161 @@ |
|||
from flask import Flask, url_for, render_template, Markup, redirect, request, flash |
|||
from flask import session as login_session |
|||
from config import Config |
|||
import json |
|||
import os |
|||
from time import gmtime, strftime |
|||
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) |
|||
|
|||
# setting variables for holding paths, folder names and the one file for description |
|||
path = "static/files/" |
|||
jsonfiles = [] #json files |
|||
fullpathjsonfiles = [] #fullpath for some situations |
|||
thefile = None #selected file for description |
|||
now = strftime("%Y-%m-%d_%H:%M:%S", gmtime()) #description time |
|||
listofdicts=[] #to be able to import and use json content |
|||
|
|||
#================================================================ |
|||
#listing the json paths |
|||
for path, subdirs, files in os.walk(path): |
|||
for name in files: |
|||
if name.endswith(".json"): |
|||
fullpath = os.path.join(path, name) |
|||
jsonfiles.append(fullpath[7:]) |
|||
fullpathjsonfiles.append(fullpath) |
|||
|
|||
print(jsonfiles) |
|||
print("-------------------------") |
|||
print(fullpathjsonfiles) |
|||
|
|||
|
|||
|
|||
|
|||
#================================================================= |
|||
#obtaining files and data |
|||
|
|||
# model for display : |
|||
# file+filename+data from json |
|||
# looping through json file, in files there is an array |
|||
# for each file in this array, display the file and the data |
|||
# send it all to the all page |
|||
|
|||
allfiles = [] |
|||
container = None |
|||
varid = None |
|||
name = None |
|||
email = None |
|||
friend = None |
|||
content = None |
|||
|
|||
for jsonname in jsonfiles: |
|||
with open("static/"+jsonname, 'r') as ajson: |
|||
data = json.load(ajson) |
|||
# allfiles.append(data["files"]) |
|||
for f in data["files"]: |
|||
# assigning html tag on the basis of extension, to be finished when all the files have been sent |
|||
if f.lower().endswith(('.png', '.jpg', '.jpeg')): |
|||
f = Markup('<img src="'+f+'" /> <br />') |
|||
|
|||
#if sound |
|||
elif f.lower().endswith(('.mp3')): |
|||
f = Markup('''<audio controls> |
|||
<source src="'''+f+'''" type="audio/mpeg"> |
|||
Your browser does not support the audio tag. |
|||
</audio>''') |
|||
#if txtfile |
|||
elif f.lower().endswith(('.txt')): |
|||
# print(thefile) |
|||
with open(f,"r") as f: |
|||
path = f.read() |
|||
f = path |
|||
|
|||
#ifvid to be added |
|||
elif f.lower().endswith(('.mp4')): |
|||
f = Markup(''' <video width="320" height="240" controls> |
|||
<source src="'''+f+'''" type="video/mp4"> |
|||
Your browser does not support the video tag. |
|||
</video> ''') |
|||
for i in data["id"]: |
|||
varid.append(i) |
|||
for j in data["name"]: |
|||
name.append(j) |
|||
|
|||
|
|||
print("-------------------------") |
|||
print(allfiles) |
|||
#Going through all folders, getting the |
|||
# thefile = listingfiles[positioninarray] |
|||
|
|||
|
|||
|
|||
@app.route("/") |
|||
def home(): |
|||
return render_template('home.html') |
|||
|
|||
@app.route('/about/') |
|||
def about(): |
|||
return render_template('about.html') |
|||
|
|||
@app.route('/all/') |
|||
def all(): |
|||
for jsonname in jsonfiles: |
|||
with open("static/"+jsonname, 'r') as ajson: |
|||
data = json.load(ajson) |
|||
allfiles.append(data["files"]) |
|||
|
|||
print(allfiles) |
|||
#Going through all folders, getting the |
|||
# thefile = listingfiles[positioninarray] |
|||
print(jsonfiles) |
|||
# print(dict) |
|||
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 |
|||
with open(jsonfiles[1], 'r') as f: |
|||
data_dict = json.load(f) |
|||
datafromjson = data_dict["files"] |
|||
|
|||
for file in datafromjson: |
|||
datafromjson = file |
|||
|
|||
# assigning html tag on the basis of extension, to be finished when all the files have been sent |
|||
if file.lower().endswith(('.png', '.jpg', '.jpeg')): |
|||
file = Markup('<img src="'+file+'" /> <br />') |
|||
|
|||
#if sound |
|||
elif file.lower().endswith(('.mp3')): |
|||
file = Markup('''<audio controls> |
|||
<source src="'''+file+'''" type="audio/mpeg"> |
|||
Your browser does not support the audio tag. |
|||
</audio>''') |
|||
#if txtfile |
|||
elif file.lower().endswith(('.txt')): |
|||
# print(thefile) |
|||
with open(file,"r") as f: |
|||
path = f.read() |
|||
file = path |
|||
|
|||
#ifvid to be added |
|||
elif file.lower().endswith(('.mp4')): |
|||
file = Markup(''' <video width="320" height="240" controls> |
|||
<source src="'''+thefile+'''" type="video/mp4"> |
|||
Your browser does not support the video tag. |
|||
</video> ''') |
|||
|
|||
|
|||
|
|||
return render_template('description.html', file=file, datafromjson=datafromjson) |
|||
|
|||
|
|||
|
|||
# if __name__ == '__main__': |
|||
# app.run(debug=True) |
Loading…
Reference in new issue