From 300c0fd9c956984d3a4d5275de4483a5e280d7db Mon Sep 17 00:00:00 2001 From: nil0j Date: Thu, 26 Sep 2024 09:28:00 +0200 Subject: updating python folder --- python/routes.py | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'python/routes.py') 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 ) + ) -- cgit v1.2.3