示例#1
0
文件: app.py 项目: hfilosa/blahggerz
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"
示例#2
0
文件: app.py 项目: hfilosa/blahggerz
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)
示例#3
0
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 = [])
示例#4
0
文件: app.py 项目: hfilosa/blahggerz
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 = [])
示例#5
0
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 = [])
示例#6
0
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 = [])
示例#7
0
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"
示例#8
0
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"
示例#9
0
def home():
        return render_template("home.html", posts = utils.getPosts())