def index(): user_id = request.args.get("user_id") # 获取get参数中的user_id if user_id != "" and user_id is not None: # 判空 cursor = mysql.connect().cursor() user_name = recom.find_user_name(cursor, user_id) items = recom.simple_recom(cursor, user_id) if len(items) > 0: goods_table = GoodsTable(items, classes=["goodsTable", "table"]) usersItem = recom.find_similar_users(cursor, user_id) sim_user_table = SimUserTable(usersItem, classes=["simiUserTable", "table"]) return render_template( "index.html", goods_table=goods_table, simi_users_table=sim_user_table, userId=user_id, userName=user_name, ) else: return render_template("index.html", userId=user_id, userName=user_name) else: return render_template("index.html")
def index(): user_id = request.args.get("user_id") # 获取get参数中的user_id if user_id != '' and user_id is not None: # 判空 cursor = mysql.connect().cursor() user_name = recom.find_user_name(cursor, user_id) items = recom.simple_recom(cursor, user_id) if len(items) > 0: goods_table = GoodsTable(items, classes=['goodsTable', 'table']) usersItem = recom.find_similar_users(cursor, user_id) sim_user_table = SimUserTable(usersItem, classes=['simiUserTable', 'table']) return render_template("index.html", goods_table=goods_table, simi_users_table=sim_user_table, userId=user_id, userName=user_name) else: return render_template("index.html", userId=user_id, userName=user_name) else: return render_template("index.html")
def test(user_id=None): cursor = mysql.connect().cursor() return str(recom.find_similar_users(cursor, user_id))