diff options
Diffstat (limited to 'python/routes.py')
-rw-r--r-- | python/routes.py | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/python/routes.py b/python/routes.py index a60584d..9567318 100644 --- a/python/routes.py +++ b/python/routes.py @@ -2,23 +2,32 @@ from flask import Flask, jsonify, request import database -def createApp(): - return Flask(__name__) - - -def createRoutes(app, connector): - @app.route("/", methods=['GET']) - def hello_world(): - arg1 = request.args.get('arg1') - arg2 = request.args.get('arg2') - return jsonify({'arg1': arg1, - 'arg2': arg2}) - - @app.route("/db", methods=['GET']) - def database_hello(): - return jsonify( - database.runQuery( - connector, - "SHOW DATABASES" - ) +app = Flask(__name__) + + +def run(): + app.run() + + +@app.route("/", methods=['GET']) +def hello_world(): + return "not here" + + +@app.route("/song", methods=['GET']) +def get_song(): + id = request.args.get('id') + name = request.args.get('name') + return jsonify(database.get_song(id=id, name=name)) + + +@app.route("/songs", methods=['GET']) +def get_filtered_songs(): + song = request.args.get('song') + album = request.args.get('album') + artist = request.args.get('artist') + return jsonify( + database.get_filtered_songs( + song=song, album=album, artist=artist ) + ) |