summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authoryuzu-eva <cafebabe@disroot.org>2025-03-11 03:04:37 +0100
committeryuzu-eva <cafebabe@disroot.org>2025-03-11 03:04:37 +0100
commite2d1d421e422790b956e57e40522630221eae02c (patch)
tree5a0fe6d84a845c2d70bed1f47d17fc259df71021 /app.py
parent1d1383ce943cf6b1ddb32b031a9c9a10e29f98fe (diff)
got website working; final touches are needed
Diffstat (limited to 'app.py')
-rwxr-xr-xapp.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/app.py b/app.py
index 33082fc..7122b06 100755
--- a/app.py
+++ b/app.py
@@ -33,7 +33,7 @@ def get_template_items(title, db):
@app.route("/~")
def index():
with database.Database() as db:
- with open(os.path.join("static", "index.md"), "r") as f:
+ with open("static/index.md", "r") as f:
return flask.render_template(
"index.html.j2",
**get_template_items("eva's site", db),
@@ -48,9 +48,17 @@ def robots():
def get_thoughts():
with database.Database() as db:
all_ = db.get_all_thoughts()
+ tree = {}
+ for id_, title, datetime, category in all_:
+ if category not in tree.keys():
+ tree[category] = [(id_, title, datetime)]
+ else:
+ tree[category].append((id_, title, str(datetime)))
+
return flask.render_template(
"thoughts.html.j2",
**get_template_items("thoughts", db),
+ tree = tree
)
@app.route("/thought")
@@ -58,7 +66,7 @@ def get_thought():
thought_id = flask.request.args.get("id", type=int)
with database.Database() as db:
try:
- title, datetime, parsed, headers, redirect = parser.get_thought_from_id(db. thought_id)
+ title, datetime, redirect, category_name, parsed, headers= parser.get_thought_from_id(db, thought_id)
except TypeError:
flask.abort(404)
return
@@ -71,7 +79,8 @@ def get_thought():
**get_template_items(title, db),
md_html = parsed,
contents_html = headers,
- datetime = "published: " + str(datetime)
+ datetime = "published: " + str(datetime),
+ category = category_name
)
if __name__ == "__main__":