コード例 #1
0
ファイル: views.py プロジェクト: makhloufi200/forums-flask
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)
コード例 #2
0
ファイル: views.py プロジェクト: makhloufi200/forums-flask
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)
コード例 #3
0
def home():
    return render_template("index.html", posts=post_store.get_all())
コード例 #4
0
def topic_get_all():
    posts = [post.__dict__ for post in post_store.get_all()]
    return jsonify(posts)
コード例 #5
0
ファイル: api.py プロジェクト: nouranHnouh/forums_flask
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)
コード例 #6
0
def api_home():
    posts = [post.__dict__() for post in post_store.get_all()]
    return jsonify(posts)
コード例 #7
0
ファイル: api.py プロジェクト: TChi91/Flask-Forums
def all_apis():
    all_posts = post_store.get_all()
    posts = [post.serialize() for post in all_posts]
    return jsonify(posts)
コード例 #8
0
def get_post():
    return render_template("posts.html", post=post_store.get_all())
コード例 #9
0
def home():
    posts = post_store.get_all()
    members = member_store.get_all()
    return render_template("index_2.html", posts=posts, members=members)