From a5d07659ebd8b581c73b620a1f8dd8a001e98ddc Mon Sep 17 00:00:00 2001 From: aj Date: Thu, 16 May 2019 16:29:40 +0100 Subject: [PATCH] formatting changes --- .gitignore | 2 ++ requirements.txt | 6 +++--- sarsoo/art/art.py | 11 ++++------- sarsoo/art/db.py | 3 +++ sarsoo/music/music.py | 19 +++++++++---------- sarsoo/sarsoo.py | 5 ++++- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index ed464f6..a5c6cbd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ *.py[cod] *$py.class +.idea + # C extensions *.so diff --git a/requirements.txt b/requirements.txt index f472fb9..8e83b1d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -Flask==1.0.2 -requests==2.20 -google.cloud.firestore==0.31.0 +Flask +requests +google-cloud.firestore diff --git a/sarsoo/art/art.py b/sarsoo/art/art.py index 97e32b3..6875dc1 100644 --- a/sarsoo/art/art.py +++ b/sarsoo/art/art.py @@ -1,7 +1,4 @@ -from flask import Blueprint, render_template, abort -from jinja2 import TemplateNotFound - -from google.cloud import firestore +from flask import Blueprint, render_template from .db import getTagDicts, getPopulatedTagDict, getPopulatedTagDicts @@ -9,7 +6,7 @@ staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/' urlprefix = 'art' art_print = Blueprint('art', __name__, template_folder='templates') -#db = firestore.Client() + @art_print.route('/') def root(): @@ -17,14 +14,14 @@ def root(): #print(tags) return render_template('art/index.html', tags = tags, staticroot = staticbucketurl, urlprefix = urlprefix) + @art_print.route('/') def tag_view(tag): tags = getPopulatedTagDict(tag) return render_template('art/all.html', staticroot = staticbucketurl, tags = [tags]) + @art_print.route('/all') def all(): - sections = getPopulatedTagDicts() - return render_template('art/all.html', staticroot = staticbucketurl, tags=sections) diff --git a/sarsoo/art/db.py b/sarsoo/art/db.py index 1692603..e278d0a 100644 --- a/sarsoo/art/db.py +++ b/sarsoo/art/db.py @@ -4,6 +4,7 @@ staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/' fs = firestore.Client() + def getTagDicts(): art_tags_collection = fs.collection(u'art_tags') @@ -20,6 +21,7 @@ def getTagDicts(): return sorted(dicts, key=lambda k: k['index']) + def getPopulatedTagDict(name): name_doc = fs.document(u'art_tags/{}'.format(name)) @@ -34,6 +36,7 @@ def getPopulatedTagDict(name): return tag_dicts + def getPopulatedTagDicts(): tag_dicts = getTagDicts() diff --git a/sarsoo/music/music.py b/sarsoo/music/music.py index f083686..d4bc338 100644 --- a/sarsoo/music/music.py +++ b/sarsoo/music/music.py @@ -1,5 +1,4 @@ -from flask import Blueprint, render_template, abort -from jinja2 import TemplateNotFound +from flask import Blueprint, render_template import requests from google.cloud import firestore @@ -17,15 +16,15 @@ def root(): fmkey = fs.document('key/fm').get().to_dict()['clientid'] params = { - 'method':'user.gettopalbums', - 'user':'sarsoo', - 'period':'1month', - 'limit':'6', - 'api_key':fmkey, - 'format':'json' + 'method': 'user.gettopalbums', + 'user': 'sarsoo', + 'period': '1month', + 'limit': '6', + 'api_key': fmkey, + 'format': 'json' } - req = requests.get(fm_url, params = params) + req = requests.get(fm_url, params=params) albums = req.json()['topalbums']['album'] @@ -33,4 +32,4 @@ def root(): for image in album['image']: image['text'] = image['#text'] - return render_template('music/index.html', albums = albums) + return render_template('music/index.html', albums=albums) diff --git a/sarsoo/sarsoo.py b/sarsoo/sarsoo.py index 5c263f7..a458968 100644 --- a/sarsoo/sarsoo.py +++ b/sarsoo/sarsoo.py @@ -8,13 +8,14 @@ from .music import music_print # Project ID is determined by the GCLOUD_PROJECT environment variable db = firestore.Client() -app = Flask(__name__, static_folder=os.path.join(os.path.dirname(__file__), '..', 'static'), template_folder = "templates") +app = Flask(__name__, static_folder=os.path.join(os.path.dirname(__file__), '..', 'static'), template_folder="templates") app.register_blueprint(art_print, url_prefix='/art') app.register_blueprint(music_print, url_prefix='/music') staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/' + @app.route('/') def main(): @@ -32,10 +33,12 @@ def main(): return render_template('index.html', staticroot = staticbucketurl, splash = splashtext, art=art) + @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]