about summary refs log tree commit diff
path: root/src/blog_node5_net.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/blog_node5_net.py')
-rw-r--r--src/blog_node5_net.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/blog_node5_net.py b/src/blog_node5_net.py
index d22608f..5761fc1 100644
--- a/src/blog_node5_net.py
+++ b/src/blog_node5_net.py
@@ -93,8 +93,13 @@ except FileNotFoundError as ex:
 
 @app.context_processor  # Always inject site title to all render_templates
 def inject_common():
-    comments, comment_headers = db.get_comments(strip_trailing_slash(flask.request.path))
-    comments_formatted = tabulate.tabulate(comments, comment_headers, tablefmt="psql")
+    url = strip_trailing_slash(flask.request.path)
+    comments, comment_headers = db.get_comments(url)
+    if comments:
+        comments_formatted = tabulate.tabulate(comments, comment_headers, tablefmt="psql")
+    else:
+        comments_formatted = f"""sqlite> SELECT COUNT(comment) FROM comment WHERE page_url = '{url}';
+0"""
 
     args = {
         'comments': comments_formatted,