2019-02-07 11:50:42 +00:00
|
|
|
from flask import Flask, render_template
|
2019-02-18 23:20:19 +00:00
|
|
|
from google.cloud import firestore
|
|
|
|
|
|
|
|
# Project ID is determined by the GCLOUD_PROJECT environment variable
|
|
|
|
db = firestore.Client()
|
2019-02-07 00:13:16 +00:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
2019-02-18 23:20:19 +00:00
|
|
|
staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/'
|
2019-02-07 00:13:16 +00:00
|
|
|
|
|
|
|
@app.route('/')
|
2019-02-16 18:28:49 +00:00
|
|
|
def main():
|
2019-02-18 23:35:51 +00:00
|
|
|
return render_template('index.html', staticroot = staticbucketurl)
|
2019-02-07 00:13:16 +00:00
|
|
|
|
2019-02-17 10:04:54 +00:00
|
|
|
@app.route('/music')
|
|
|
|
def music():
|
|
|
|
return render_template('music.html')
|
2019-02-16 18:28:49 +00:00
|
|
|
|
2019-02-17 13:05:06 +00:00
|
|
|
@app.route('/art')
|
|
|
|
def art():
|
2019-02-18 23:20:19 +00:00
|
|
|
art_collection = db.collection(u'art')
|
2019-02-19 11:52:25 +00:00
|
|
|
#art_tags_collection = db.collection(u'art_tags')
|
2019-02-18 23:20:19 +00:00
|
|
|
|
|
|
|
try:
|
2019-02-19 11:52:25 +00:00
|
|
|
pics = art_collection.get()
|
|
|
|
#tags = art_tags_collection.get()
|
2019-02-18 23:20:19 +00:00
|
|
|
except google.cloud.exceptions.NotFound:
|
|
|
|
return 'no such document'
|
2019-02-19 11:52:25 +00:00
|
|
|
|
|
|
|
#categories = []
|
|
|
|
#for tag in tags:
|
|
|
|
#taglist = {
|
|
|
|
#tag.to_dict()['name'] : []
|
|
|
|
#}
|
|
|
|
#print(tag.to_dict())
|
|
|
|
#categories.append(taglist)
|
2019-02-18 23:20:19 +00:00
|
|
|
|
2019-02-19 11:52:25 +00:00
|
|
|
#print(categories)
|
|
|
|
|
2019-02-18 23:20:19 +00:00
|
|
|
images = []
|
2019-02-19 11:52:25 +00:00
|
|
|
for doc in pics:
|
|
|
|
#image = doc.to_dict()
|
|
|
|
images.append(doc.to_dict())
|
|
|
|
#categories[categories.index(image['tag'])].append(image)
|
2019-02-18 23:20:19 +00:00
|
|
|
|
|
|
|
return render_template('art.html', staticroot = staticbucketurl, images=images)
|
2019-02-17 13:05:06 +00:00
|
|
|
|
|
|
|
@app.route('/dev')
|
|
|
|
def dev():
|
|
|
|
return render_template('dev.html')
|
|
|
|
|
2019-02-07 00:13:16 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run(host='127.0.0.1', port=8080, debug=True)
|
|
|
|
# [END gae_python37_app]
|