formatting changes

This commit is contained in:
aj 2019-05-16 16:29:40 +01:00
parent a56ec131de
commit a5d07659eb
6 changed files with 25 additions and 21 deletions

2
.gitignore vendored
View File

@ -3,6 +3,8 @@
*.py[cod]
*$py.class
.idea
# C extensions
*.so

View File

@ -1,3 +1,3 @@
Flask==1.0.2
requests==2.20
google.cloud.firestore==0.31.0
Flask
requests
google-cloud.firestore

View File

@ -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('/<tag>')
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)

View File

@ -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()

View File

@ -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)

View File

@ -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]