Skip to content

Commit

Permalink
converted response to json
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylong committed Nov 22, 2023
1 parent c5a2d32 commit 5c01d24
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cornac/serving/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import os
import pickle
from flask import Flask, request
from flask import Flask, jsonify, request
from csv import writer


Expand Down Expand Up @@ -91,7 +91,12 @@ def recommend():
train_set=train_set,
)

return response
data = {
"recommendations": response,
"query": {"uid": uid, "k": k, "remove_seen": remove_seen},
}

return jsonify(data), 200

@app.route("/feedback", methods=["POST"])
def add_feedback():
Expand All @@ -111,7 +116,12 @@ def add_feedback():
csv_writer.writerow([uid, iid, rating])
write_obj.close()

return "Feedback added", 200
data = {
"message": "Feedback added",
"data": f"uid: {uid}, iid: {iid}, rating: {rating}"
}

return jsonify(data), 200


if __name__ == "__main__":
Expand Down

0 comments on commit 5c01d24

Please sign in to comment.