diff options
author | nil0j <nil.jimeno@estudiant.fjaverianas.com> | 2024-09-26 09:28:00 +0200 |
---|---|---|
committer | nil0j <nil.jimeno@estudiant.fjaverianas.com> | 2024-09-26 09:28:00 +0200 |
commit | 300c0fd9c956984d3a4d5275de4483a5e280d7db (patch) | |
tree | 36c42a39fcb86bbc4937512db9c39a851cda4e85 /python/routes.py | |
parent | 14662002d50908f83342c44594b81a5a8833a286 (diff) |
updating python folder
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 ) + ) |