diff options
author | ubq323 <ubq323> | 2021-05-22 15:12:30 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-05-22 15:12:30 +0000 |
commit | eb298f0c63eb6ac5547a6a7a0086e5e086ad5abc (patch) | |
tree | 4384e1036841a1b051832bffbee0ffb8a3b6cb8d /apioforum/thread.py | |
parent | 76120509b4ff409c6642b837be95ebc72c529d4b (diff) |
thread view, also fix file extensions
Diffstat (limited to 'apioforum/thread.py')
-rw-r--r-- | apioforum/thread.py | 19 |
1 files changed, 19 insertions, 0 deletions
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/<int:thread_id>") +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) + |