def index(): if "logged_in" not in session: session["logged_in"] = False if "user" not in session: session["user"] = "******" if request.method == "GET": return render_template("index.html", log="", s=session) if request.method == "POST": button = request.form["button"] username = request.form["username"] password = request.form["password"] if button == "Login": result = utils.authenticate(username, password) if result == "success": currentUser = username session["user"] = username session["logged_in"] = True session["posts"] = utils.getPosts() return redirect("/posts") elif result == "noUser": return render_template("index.html", log="noUser", s=session) else: return render_template("index.html", log="fail", s=session) else: return "bye"
def posts(): posts = utils.getPosts() if session["logged_in"] == False: return redirect("/index") if request.method == "GET": return render_template("posts.html", username=session["user"], posts=posts, comments=[], s=session) if request.method == "POST": button = request.form["button0"] if button == "Write New Post": return redirect("/postnew") # ("postnew.html", username = currentUser) return render_template("posts.html", username=session["user"], posts=posts, comments=[], s=session)
def posts(): posts = utils.getPosts() if session['logged_in'] == False: return redirect('/index') if request.method=="GET": return render_template("posts.html", username = session['user'], posts = posts, comments = []) if request.method=="POST": button = request.form['button0'] if button == "Write New Post": return redirect("/postnew") #("postnew.html", username = currentUser) return render_template("posts.html", username = session['user'], posts = posts, comments = [])
def postnew(): if session["logged_in"] == False: return redirect("/index") if request.method == "GET": return render_template("postnew.html", username=session["user"], s=session) if request.method == "POST": postButton = request.form["postButton"] uname = session["user"] time = datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d %H:%M:%S") msg = request.form["post"] utils.addPost(uname, time, msg) posts = utils.getPosts() return redirect("/posts") # render_template("posts.html", username = currentUser, posts = posts, comments = [])
def postnew(): if session['logged_in'] == False: return redirect('/index') if request.method=="GET": return render_template("postnew.html", username = session['user']) if request.method=="POST": postButton = request.form['postButton'] uname = session['user'] time = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') msg = request.form['post'] utils.addPost(uname, time, msg) posts = utils.getPosts() return redirect("/posts") #render_template("posts.html", username = currentUser, posts = posts, comments = [])
def postnew(): if session['logged_in'] == False: return redirect('/index') if request.method == "GET": return render_template("postnew.html", username=session['user']) if request.method == "POST": postButton = request.form['postButton'] uname = session['user'] time = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') msg = request.form['post'] utils.addPost(uname, time, msg) posts = utils.getPosts() return redirect( "/posts" ) #render_template("posts.html", username = currentUser, posts = posts, comments = [])
def index(): if 'logged_in' not in session: session['logged_in'] = False if 'user' not in session: session['user'] = '******' if request.method=="GET": return render_template("index.html", log = "" ) if request.method=="POST": button = request.form['button'] username=request.form['username'] password=request.form['password'] if button=="Login": if utils.authenticate(username,password) == "success": currentUser = username session['user'] = username session['logged_in'] = True posts = utils.getPosts() return redirect("/posts") elif utils.authenticate(username,password) == "noUser": return render_template("index.html", log = "noUser") else: return render_template("index.html", log = "fail") else: return "bye"
def index(): if 'logged_in' not in session: session['logged_in'] = False if 'user' not in session: session['user'] = '******' if request.method == "GET": return render_template("index.html", log="") if request.method == "POST": button = request.form['button'] username = request.form['username'] password = request.form['password'] if button == "Login": if utils.authenticate(username, password) == "success": currentUser = username session['user'] = username session['logged_in'] = True posts = utils.getPosts() return redirect("/posts") elif utils.authenticate(username, password) == "noUser": return render_template("index.html", log="noUser") else: return render_template("index.html", log="fail") else: return "bye"
def home(): return render_template("home.html", posts = utils.getPosts())