def unfollow(): try: unfollow_id = request.form['unfollow'] uid = request.cookies["userID"] unfollow_id = str(unfollow_id) if bc.is_following(uid, unfollow_id): bc.unfollow(uid, unfollow_id) return redirect(request.form['path']) except KeyError: print(KeyError, " keyerror for username") return redirect('/')
def show_profile(userID=0): try: if request.method == 'POST': searching = request.form['searching'] return redirect('/searchresult/%s' % urllib.parse.quote(searching)) if userID == 0: userID = int(request.cookies['userID']) myuid = request.cookies['userID'] myself = (userID == int(myuid)) follow = bc.is_following(str(myuid), str(userID)) infos = bc.genUserInfo(userID) posts = bc.user_weibos(userID, myuid) username = request.cookies['username'] return render_template("profile.html", username=username, myself=myself, follow=follow, infos=infos, posts=posts, title='个人主页') except KeyError: print(KeyError, " keyerror for username") return redirect('/')
def show_follower(userID=0): try: if request.method == 'POST': searching = request.form['searching'] return redirect('/searchresult/%s' % urllib.parse.quote(searching)) else: myUserID = int(request.cookies['userID']) if userID == 0: userID = myUserID myself = (userID == myUserID) follow = bc.is_following(str(myUserID), str(userID)) infos = bc.genUserInfo(userID) followers = bc.genFollowers(userID, myUserID) username = request.cookies['username'] return render_template("followers.html", username=username, myself=myself, follow=follow, infos=infos, users=followers, title='粉丝列表') except KeyError: print(KeyError, " keyerror for username") return redirect('/')