diff --git a/package-lock.json b/package-lock.json index 8f9327f..9f0471a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1192,6 +1192,22 @@ "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, + "axios": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", + "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "requires": { + "follow-redirects": "1.5.10", + "is-buffer": "^2.0.2" + }, + "dependencies": { + "is-buffer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", + "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + } + } + }, "babel-loader": { "version": "8.0.6", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.6.tgz", @@ -2310,6 +2326,29 @@ "readable-stream": "^2.3.6" } }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", diff --git a/package.json b/package.json index 8794e1c..03ca714 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "webpack-merge": "^4.2.1" }, "dependencies": { + "axios": "^0.19.0", "react": "^16.8.6", "react-dom": "^16.8.6" } diff --git a/sarsoo/api/__init__.py b/sarsoo/api/__init__.py index 2783394..7cd0bff 100644 --- a/sarsoo/api/__init__.py +++ b/sarsoo/api/__init__.py @@ -1 +1,2 @@ from .art_api import art_api_print +from .dev_api import dev_api_print \ No newline at end of file diff --git a/sarsoo/api/dev_api.py b/sarsoo/api/dev_api.py new file mode 100644 index 0000000..694cea6 --- /dev/null +++ b/sarsoo/api/dev_api.py @@ -0,0 +1,41 @@ +from flask import Blueprint, jsonify, abort +from google.cloud import firestore, exceptions + +fs = firestore.Client() + +dev_api_print = Blueprint('devapi', __name__) + + +@dev_api_print.route('/', methods=['GET']) +def collections(): + + dev_collection = fs.collection(u'dev') + + try: + tags = dev_collection.get() + except exceptions.NotFound: + abort(404) + + dicts = list(map(lambda x: x.to_dict(), tags)) + + dev_documents = [] + + for dev_dict in dicts: + dev_documents.append({ + 'name': dev_dict['name'], + 'description': [i for i in dev_dict['description']], + 'url': dev_dict['url'], + 'index': dev_dict['index'] + }) + + response = {'dev': sorted(dev_documents, key=lambda k: k['index'])} + + return jsonify(response) + + +@dev_api_print.errorhandler(404) +def error400(error): + + errorresponse = {'error': 'collection not found'} + + return jsonify(errorresponse), 404 diff --git a/sarsoo/sarsoo.py b/sarsoo/sarsoo.py index ef5c574..f51f41b 100644 --- a/sarsoo/sarsoo.py +++ b/sarsoo/sarsoo.py @@ -5,6 +5,7 @@ import os from .art import art_print from .music import music_print from .api import art_api_print +from .api import dev_api_print # Project ID is determined by the GCLOUD_PROJECT environment variable db = firestore.Client() @@ -14,6 +15,7 @@ app = Flask(__name__, static_folder=os.path.join(os.path.dirname(__file__), '..' app.register_blueprint(art_print, url_prefix='/art') app.register_blueprint(music_print, url_prefix='/music') app.register_blueprint(art_api_print, url_prefix='/api/art') +app.register_blueprint(dev_api_print, url_prefix='/api/dev') staticbucketurl = 'https://storage.googleapis.com/sarsooxyzstatic/' diff --git a/sarsoo/templates/dev.html b/sarsoo/templates/dev.html index fab0bc7..5e7c492 100644 --- a/sarsoo/templates/dev.html +++ b/sarsoo/templates/dev.html @@ -3,19 +3,6 @@ {% block title %}dev{% endblock %} {% block content %} -
a client for last.fm music tracking written in java
-this project was important for learning how to interact with REST APIs and implementing knowledge from my java classes at uni
-using last fm tags to categorise and visualise data
- view source -tool for exploring and interfacing with the spotify api
-currently doing backups of playlists
- view source -loading...
; + + return this.state.isLoading ? loadingMessage : gallery; + } + +} + +function Row(props){ + + return ( +