mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-28 22:03:10 +00:00
Update search path
This commit is contained in:
parent
7cdb22984b
commit
966d377adb
2 changed files with 27 additions and 7 deletions
|
@ -85,13 +85,33 @@ def post():
|
||||||
return "Success!", 200
|
return "Success!", 200
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/users", methods=["GET"])
|
@blueprint.route("/search", methods=["GET"])
|
||||||
def users():
|
def search():
|
||||||
search = request.args.get("search")
|
search_arg = request.args.get("q")
|
||||||
|
|
||||||
if not search:
|
if not search_arg:
|
||||||
return "No search query provided!", 400
|
return "No search query provided!", 400
|
||||||
|
|
||||||
search_results = Users.query.filter(Users.username.contains(search)).limit(MAX_SEARCH_RESULTS).all()
|
users = Users.query.filter(Users.username.contains(search)).limit(MAX_SEARCH_RESULTS).all()
|
||||||
|
|
||||||
return jsonify([result.username for result in search_results]), 200
|
return jsonify([user.username for user in users]), 200
|
||||||
|
|
||||||
|
|
||||||
|
# @blueprint.route("/login", methods=["POST"])
|
||||||
|
# def login():
|
||||||
|
# username = request.form["username"]
|
||||||
|
# password = request.form["password"]
|
||||||
|
# errors = []
|
||||||
|
#
|
||||||
|
# if not username:
|
||||||
|
# errors += "Empty Username"
|
||||||
|
# if not password:
|
||||||
|
# errors += "Empty Password"
|
||||||
|
#
|
||||||
|
# if errors:
|
||||||
|
# return jsonify(errors), 400
|
||||||
|
#
|
||||||
|
# user = Users.query.filter(username=username).first()
|
||||||
|
# if not user:
|
||||||
|
# errors += "No user found"
|
||||||
|
#
|
||||||
|
|
|
@ -37,7 +37,7 @@ function getSearch() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch('/api/users?search=' + search.toString(), {
|
fetch('/api/search?q=' + search.toString(), {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue