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)
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)
def home(): return render_template("index.html", posts=post_store.get_all())
def topic_get_all(): posts = [post.__dict__ for post in post_store.get_all()] return jsonify(posts)
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)
def api_home(): posts = [post.__dict__() for post in post_store.get_all()] return jsonify(posts)
def all_apis(): all_posts = post_store.get_all() posts = [post.serialize() for post in all_posts] return jsonify(posts)
def get_post(): return render_template("posts.html", post=post_store.get_all())
def home(): posts = post_store.get_all() members = member_store.get_all() return render_template("index_2.html", posts=posts, members=members)