From eb298f0c63eb6ac5547a6a7a0086e5e086ad5abc Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 22 May 2021 15:12:30 +0000 Subject: thread view, also fix file extensions --- apioforum/thread.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 apioforum/thread.py (limited to 'apioforum/thread.py') diff --git a/apioforum/thread.py b/apioforum/thread.py new file mode 100644 index 0000000..24b7766 --- /dev/null +++ b/apioforum/thread.py @@ -0,0 +1,19 @@ +# view posts in thread + +from flask import ( + Blueprint, render_template +) +from .db import get_db + +bp = Blueprint("thread", __name__, url_prefix="/thread") + +@bp.route("/view/") +def view_thread(thread_id): + db = get_db() + thread = db.execute("SELECT * FROM threads WHERE id = ?;",(thread_id,)).fetchone() + if thread is None: + abort(404) + else: + posts = db.execute("SELECT * FROM posts WHERE thread = ? ORDER BY idx;",(thread_id,)).fetchall() + return render_template("view_thread.html",posts=posts,thread=thread) + -- cgit v1.2.3