From 830970958337851a4b0e5c3f7868bccd82a7fca6 Mon Sep 17 00:00:00 2001 From: aj Date: Tue, 19 Feb 2019 22:31:18 +0000 Subject: [PATCH] database defined art on index page, added splash text --- main.py | 24 ++++++++++++++---------- templates/index.html | 7 ++++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index f9b0437..e4e4e7c 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,20 @@ staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/' @app.route('/') def main(): - return render_template('index.html', staticroot = staticbucketurl) + + index_doc = db.collection(u'pages').document(u'index') + doc = index_doc.get() + index_dict = doc.to_dict() + + splashtext = index_dict['splash_text'] + + art = [] + for image in index_dict['art']: + art.append(image.get().to_dict()) + + print(index_dict['art'][0].get().to_dict()) + + return render_template('index.html', staticroot = staticbucketurl, splash = splashtext, art=art) @app.route('/music') def music(): @@ -22,7 +35,6 @@ def art(): art_tags_collection = db.collection(u'art_tags') try: - #pics = art_collection.get() tags = art_tags_collection.get() except google.cloud.exceptions.NotFound: return 'no such document' @@ -42,14 +54,6 @@ def art(): #sections.append({tag_dict['name']: image_list}) sections.append({'images': image_list, 'name': tag_dict['name'], 'description': tag_dict['description'], 'index': tag_dict['index']}) - #print(sections[0]) - - images = [] - for doc in pics: - #image = doc.to_dict() - images.append(doc.to_dict()) - #categories[categories.index(image['tag'])].append(image) - return render_template('art.html', staticroot = staticbucketurl, tags=sections) @app.route('/dev') diff --git a/templates/index.html b/templates/index.html index 5f65104..205aa12 100644 --- a/templates/index.html +++ b/templates/index.html @@ -9,6 +9,7 @@

electronic engineering student / disney intern

proficient in C, Java, Python

+ {% if splash %}

{{ splash }}

{% endif %}
@@ -17,8 +18,8 @@
- freddie gibbs - me - tempation of saint anthony + {% for image in art %} + {{ image.file_name  }} + {% endfor %}
{% endblock %}