diff --git a/.gcloudignore b/.gcloudignore index a987f11..8db52e9 100644 --- a/.gcloudignore +++ b/.gcloudignore @@ -16,4 +16,6 @@ # Python pycache: __pycache__/ # Ignored by the build system -/setup.cfg \ No newline at end of file +/setup.cfg + +env diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a764a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +env diff --git a/main.py b/main.py index 4d45dc8..c43f0d2 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,12 @@ from flask import Flask, render_template +from google.cloud import firestore + +# Project ID is determined by the GCLOUD_PROJECT environment variable +db = firestore.Client() app = Flask(__name__) +staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/' @app.route('/') def main(): @@ -13,13 +18,24 @@ def music(): @app.route('/art') def art(): - return render_template('art.html') + art_collection = db.collection(u'art') + + try: + docs = art_collection.get() + except google.cloud.exceptions.NotFound: + return 'no such document' + + images = [] + for doc in docs: + image = doc.to_dict() + images.append(image) + + return render_template('art.html', staticroot = staticbucketurl, images=images) @app.route('/dev') def dev(): return render_template('dev.html') - if __name__ == '__main__': app.run(host='127.0.0.1', port=8080, debug=True) # [END gae_python37_app] diff --git a/templates/art.html b/templates/art.html index 8bbcdb7..923d51f 100644 --- a/templates/art.html +++ b/templates/art.html @@ -1,59 +1,17 @@ {% extends 'base.html' %} + {% block title %}art{% endblock %} {% block content %} - -
-

portraits

-
-
-
- freddie gibbs -

freddie gibbs / piñata

-
-
- me -

self portrait

-
-
- tyler, the creator -

tyler, the creator

-
-
-
-

animals

-
-
-
- gorilla -

gorilla

-
-
- zuma -

zuma

-
-
- temptation of saint anthony -

the temptation of saint anthony / salvador dalí

-
-
-
-

life drawing

-
-
-
- brown -

white and brown

-
-
- outline -

minimal outline

-
-
- red and blue -

red and blue

-
-
+ {% for image in images %} + {% if loop.index0 % 3 == 0 %}
{% endif %} +
+ {{ image.file_name  }} +

{{ image.description }}

+
+ {% if loop.index % 3 == 0 or loop.last %}
{% endif %} + + {% endfor %} {% endblock %}