Commit bcd0c2a8 authored by Fabian Wandt's avatar Fabian Wandt

Suche von Usern über username anstatt uid

parent a39c19ec
Pipeline #24008 failed with stages
......@@ -7,6 +7,8 @@ import os
#User erstellen
@app.route('/user', methods=['POST'])
def add_user():
......@@ -30,15 +32,15 @@ def get_users():
return jsonify(result)
#Ausgabe eines einzelnen Users
@app.route('/user/<id>', methods=['GET'])
def get_user(id):
user = User.query.get(id)
@app.route('/user/<username>', methods=['GET'])
def get_user(username):
user = User.query.filter_by(username= username).first()
return user_schema.jsonify(user)
#Bearbeiten eines Users
@app.route('/user/<id>', methods=['PUT'])
def update_user(id):
user = User.query.get(id)
@app.route('/user/<username>', methods=['PUT'])
def update_user(username):
user = User.query.filter_by(username= username).first()
vname = request.json['vname']
nname = request.json['nname']
......@@ -55,9 +57,9 @@ def update_user(id):
return user_schema.jsonify(user)
#Löschen eines Users
@app.route('/user/<id>', methods=['DELETE'])
def delete_user(id):
user = User.query.get(id)
@app.route('/user/<username>', methods=['DELETE'])
def delete_user(username):
user = User.query.filter_by(username= username).first()
db.session.delete(user)
db.session.commit()
......
......@@ -25,7 +25,7 @@ def post():
#Delete Request: User Delete
def delete():
print("DELETE")
url = "http://0.0.0.0:5000/user/1"
url = "http://0.0.0.0:5000/user/kmueller"
r = requests.delete(url)
print(r.status_code)
print(r.content)
......@@ -33,7 +33,7 @@ def delete():
#Put Request: User Update
def put():
print("PUT")
url = "http://0.0.0.0:5000/user/1"
url = "http://0.0.0.0:5000/user/hpotter"
data = {'vname': 'kevin', 'nname': 'mueller', 'username':'kmueller','aktiv':'nein'}
header = {'Content-type': 'application/json'}
r = requests.put(url,data=json.dumps(data), headers=header)
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment