From 1a4b38dfe2cd5899fd3c9682f50c5f7b62dd1232 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Sat, 25 Nov 2023 18:42:53 +0100 Subject: [PATCH] get und post in der api --- Website/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Website/__init__.py b/Website/__init__.py index 34dabbc..ac88ef2 100644 --- a/Website/__init__.py +++ b/Website/__init__.py @@ -306,11 +306,14 @@ def create_app(test_config=None): leave_room(session[id]) #api - @app.route("/api/change", methods=['POST']) + @app.route("/api/change", methods=['GET', 'POST']) def api_change(): db = get_db() c = db.cursor() - userid = request.form["id"] + try: + userid = request.form["id"] + except: + userid = request.args.get("id") c.execute("SELECT * FROM users WHERE id=?", [userid]) user_list = c.fetchall() if user_list != []: @@ -330,13 +333,16 @@ def create_app(test_config=None): return make_response(json.dumps({"mode":"error","error":"043"})) - @app.route("/api/tag_id", methods=['GET']) + @app.route("/api/tag_id", methods=['GET', 'POST']) def get_id(): global finished global message db = get_db() c = db.cursor() - tag_id = request.args.get("id") + try: + tag_id = request.form["id"] + except: + tag_id = request.args.get("id") c.execute(f"SELECT * FROM tags WHERE tagid=?", [tag_id]) tag_list = c.fetchall()