Exemplo n.º 1
0
def edit(post_id):
    if request.method == "GET":
        post = dictify(Post.get_one(post_id=post_id))
        return render_template("edit.html", post=post)
    else:
        title = str(request.form.get("title"))
        body = request.form.get("body")
        category = request.form.get("category")
        user_id = "samjunior101"

        data = {
            u'title': title,
            u'body': body,
            u'user_id': user_id,
            u'category': category
        }

        Post.save(data=data, post_id=post_id)
        return redirect(url_for("index"))
Exemplo n.º 2
0
def show(post_id):
    post = dictify(Post.get_one(post_id=post_id))
    return render_template("show.html", post=post)