def notification(): "notification method called" count = get.get_timeline_count(session["emailid"]) diff = count - session["tweet_count"] if diff < 0: session["tweet_count"] = count return jsonify({"count": diff})
def home(): startval = request.args.get("start") startval = int(startval) session["tweet_count"] = get.get_timeline_count(session["emailid"]) session["other_user"] = session["username"] session["other_email"] = session["emailid"] uid = session["emailid"] info = get.get_userinfo(uid) d, l = get.get_timeline(uid) d2 = get.get_retweets(session["emailid"]) d1, l1 = get.get_favourite(session["emailid"]) current_trends = tweets.current_trends() if len(l) > startval + 5: limit = startval + 5 nextt = limit else: limit = len(l) nextt = 0 l = l[startval:limit] if startval == 0: return render_template( "home.html", info=info, d=d, l=l, retweet=d2, f=l1, start=int(nextt), trends=current_trends ) else: return jsonify({"d": d, "l": l, "retweet": d2, "f": l1, "start": nextt, "trends": current_trends})
def login(): if "emailid" in session: return redirect(url_for("get_userline")) if request.method == "POST": email = request.form["emailid"] pwd = request.form["password"] val = users.checkUser(email, pwd) if val != str(0): session["username"] = val session["emailid"] = request.form["emailid"] session["other_user"] = session["username"] session["other_email"] = session["emailid"] session["tweet_count"] = get.get_timeline_count(session["emailid"]) else: message = "Incorrect password or username" return render_template("login.html", message=message) return redirect(url_for("get_userline")) else: return render_template("login.html", message="")