Handle article not found
This commit is contained in:
parent
f17dadd5a3
commit
2773f94b36
2 changed files with 14 additions and 2 deletions
|
@ -84,7 +84,7 @@ def index():
|
|||
diffs = db.fetchall()
|
||||
|
||||
html = render_template(
|
||||
"./index.html",
|
||||
"index.html",
|
||||
diffs=diffs,
|
||||
page=page,
|
||||
pagination=pagination,
|
||||
|
@ -104,8 +104,12 @@ def article_detail(article_id: str):
|
|||
db = get_db().cursor()
|
||||
db.execute("SELECT * FROM diffs WHERE article_id = ?", (article_id,))
|
||||
result = db.fetchall()
|
||||
|
||||
if len(result) == 0:
|
||||
return make_response(render_template("not_found.html"), 404)
|
||||
|
||||
article_url = result[0]["article_url"]
|
||||
# TODO: Handle if nothing is found and return 404 in that case.
|
||||
|
||||
return render_template(
|
||||
"article_detail.html",
|
||||
article_id=article_id,
|
||||
|
|
8
view/templates/not_found.html
Normal file
8
view/templates/not_found.html
Normal 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 %}
|
Loading…
Reference in a new issue