Handle article not found

This commit is contained in:
Ondřej 2023-08-21 10:56:04 +02:00
parent f17dadd5a3
commit 2773f94b36
2 changed files with 14 additions and 2 deletions

View file

@ -84,7 +84,7 @@ def index():
diffs = db.fetchall() diffs = db.fetchall()
html = render_template( html = render_template(
"./index.html", "index.html",
diffs=diffs, diffs=diffs,
page=page, page=page,
pagination=pagination, pagination=pagination,
@ -104,8 +104,12 @@ def article_detail(article_id: str):
db = get_db().cursor() db = get_db().cursor()
db.execute("SELECT * FROM diffs WHERE article_id = ?", (article_id,)) db.execute("SELECT * FROM diffs WHERE article_id = ?", (article_id,))
result = db.fetchall() result = db.fetchall()
if len(result) == 0:
return make_response(render_template("not_found.html"), 404)
article_url = result[0]["article_url"] article_url = result[0]["article_url"]
# TODO: Handle if nothing is found and return 404 in that case.
return render_template( return render_template(
"article_detail.html", "article_detail.html",
article_id=article_id, article_id=article_id,

View file

@ -0,0 +1,8 @@
{% extends "base.html" %}
{% block body %}
<div class="container my-6 flex items-center gap-2">
<p class="text-4xl">😭</p>
<h1 class="text-xl font-medium">Nenalezeno</h1>
</div>
{% endblock body %}