本文整理汇总了Python中backend.Backend.get_recommendations方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.get_recommendations方法的具体用法?Python Backend.get_recommendations怎么用?Python Backend.get_recommendations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend.Backend
的用法示例。
在下文中一共展示了Backend.get_recommendations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UIDClientHandler
# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import get_recommendations [as 别名]
class UIDClientHandler(threading.Thread):
def __init__(self, clientsocket):
super(UIDClientHandler, self).__init__()
self.clientsocket = clientsocket
self.ass = Backend()
def generate_response(self, request):
"""
Use the servers stored data to respond to a client
Returns the appropriate response
"""
global uids
resp = {}
liked = request["liked"]
disliked = request["disliked"]
images = self.ass.get_recommendations(liked, disliked)
print "REC: {}".format(images)
resp["type"] = "OK"
resp["recommendations"] = images
# resp["type"] = "ERROR"
# resp["body"] = "Exception while handling request"
return resp
def run(self):
"""
Client handling Thread
"""
print "Connected to {}".format(self.clientsocket.getpeername())
while True:
try:
reqstr = self.clientsocket.recvln()
if not reqstr:
return
req = json.loads(base64.b64decode(reqstr))
print "REQ: {}".format(req)
resp = self.generate_response(req)
print "RESP: {}".format(resp)
respstr = base64.b64encode(json.dumps(resp))
self.clientsocket.sendln(respstr)
except socket.error:
return