Skip to content

Commit fb9d59c

Browse files
Update ml_api.py
platformid and k are optional parameters, with default value None.
1 parent cceea62 commit fb9d59c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ml_api.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ def home():
1414
@app.route("/recommendations", methods = ['GET', 'POST'])
1515
def recommend():
1616
program = request.args.get("program")
17-
k = int(request.args.get("k")) + 1
17+
if request.args.get("platformid"):
18+
platformid = int(request.args.get("platformid"))
19+
else:
20+
platformid = None
21+
if request.args.get("k"):
22+
k = int(request.args.get("k")) + 1
23+
else:
24+
k = None
1825
recommendations = recommender.get_recommendations(
19-
program, recommender.cosine_sim, k)
26+
program, platformid, recommender.cosine_sim, k)
2027
return jsonify(recommendations)
2128

2229

0 commit comments

Comments
 (0)