diff --git a/senju/main.py b/senju/main.py
index fd2e795..4f16689 100644
--- a/senju/main.py
+++ b/senju/main.py
@@ -24,20 +24,18 @@ def index_view():
def haiku_index_view():
haiku_id: int | None = store.get_id_of_latest_haiku()
if haiku_id is None:
- # TODO: add "empty haiku list" error page
- raise KeyError("no haiku exist yet")
- return redirect(url_for("haiku_view", haiku_id=haiku_id))
+ haiku_id = 0
+ return redirect(url_for("haiku_view", haiku_id=haiku_id, is_default=1))
@app.route("/haiku/")
def haiku_view(haiku_id):
"""test"""
- haiku: Haiku | None = store.load_haiku(haiku_id)
- if haiku is None:
- # TODO: add "haiku not found" page
- raise KeyError("haiku not found")
+ is_default: bool = request.args.get("is_default") == "1"
+ haiku: Haiku = store.load_haiku(haiku_id)
context: dict = {
- "haiku": haiku
+ "haiku": haiku,
+ "is_default": is_default
}
return render_template(
diff --git a/senju/templates/haiku.html b/senju/templates/haiku.html
index 844dfff..c3d4382 100644
--- a/senju/templates/haiku.html
+++ b/senju/templates/haiku.html
@@ -11,6 +11,11 @@
{% endfor %}
+ {% if context.is_default %}
+
+ Note: No haikus have been found in the haiku store.
+
+ {% endif %}
Back to Home