Esempio n. 1
0
def topic_show(id):
    posts = post_store.get_all()
    found_post = [post for post in posts if post.id == id][0]
    if request.method == "POST":
        return redirect(url_for("home"))
    else:
        return render_template("topic_show.html", post=found_post)
Esempio n. 2
0
def topic_edit(id):
    posts = post_store.get_all()
    found_post = [post for post in posts if post.id == id][0]
    if request.method == "POST":
        updated_post = post_store.get_by_id(id)
        updated_post.title = request.form["title"]
        updated_post.content = request.form["content"]
        post_store.update(updated_post)
        return redirect(url_for("home"))

    else:
        return render_template("topic_edit.html", post=found_post)
Esempio n. 3
0
def home():
    return render_template("index.html", posts=post_store.get_all())
Esempio n. 4
0
def topic_get_all():
    posts = [post.__dict__ for post in post_store.get_all()]
    return jsonify(posts)
Esempio n. 5
0
def topic_get_all():
    #convert every objects in the list to dictionary format
    posts = [post.__dict__() for post in post_store.get_all()]
    #use jsonify to convert objects to JSON format
    return jsonify(posts)
Esempio n. 6
0
def api_home():
    posts = [post.__dict__() for post in post_store.get_all()]
    return jsonify(posts)
Esempio n. 7
0
def all_apis():
    all_posts = post_store.get_all()
    posts = [post.serialize() for post in all_posts]
    return jsonify(posts)
Esempio n. 8
0
def get_post():
    return render_template("posts.html", post=post_store.get_all())
Esempio n. 9
0
def home():
    posts = post_store.get_all()
    members = member_store.get_all()
    return render_template("index_2.html", posts=posts, members=members)