From 6c2f7427f742243cbee8f3fce3d6c5fdb9339d0d Mon Sep 17 00:00:00 2001 From: 0x01FE <0x10FE@0x01fe.net> Date: Tue, 23 Apr 2024 11:11:54 -0500 Subject: [PATCH] made a template for the writing page --- app/app.py | 28 ++++++++++++++++++++++++++++ app/static/writing.html | 9 --------- app/templates/about.html | 1 + app/templates/games.html | 1 + app/templates/index.html | 2 +- app/templates/motion-pictures.html | 1 + app/templates/music.html | 1 + app/templates/programming.html | 1 + app/templates/writing.html | 11 +++++++++++ 9 files changed, 45 insertions(+), 10 deletions(-) delete mode 100644 app/static/writing.html create mode 100644 app/templates/writing.html diff --git a/app/app.py b/app/app.py index a28e1e1..a7e1217 100644 --- a/app/app.py +++ b/app/app.py @@ -1,6 +1,8 @@ +import os import glob import configparser import random +import datetime import requests import flask @@ -15,6 +17,7 @@ CONFIG_PATH = "./config.ini" config = configparser.ConfigParser() config.read(CONFIG_PATH) +WRITING_FOLDER = 'static/writing/' POSTS_FOLDER = config['POSTS']['POSTS_FOLDER'] STATUS_FILE = config['STATUS']['STATUS_FILE'] PORT = int(config['NETWORK']['PORT']) @@ -161,6 +164,31 @@ def programming(): return flask.render_template('programming.html', posts=post_bodies, status=status) +@app.route('/writing/') +def writing(): + + works = [] + + # Get all works in writing folder + files = glob.glob(WRITING_FOLDER + '*') + + for path in files: + + date: str = datetime.datetime.fromtimestamp(os.path.getctime(path)).strftime("%B %d, %Y") + name: str = path.split('/')[-1] + + works.append({ + 'date' : date, + 'name' : name, + 'path' : path + }) + + return flask.render_template('writing.html', works=works) + + + + + # About Page @app.route('/about/') def about(): diff --git a/app/static/writing.html b/app/static/writing.html deleted file mode 100644 index 44de92c..0000000 --- a/app/static/writing.html +++ /dev/null @@ -1,9 +0,0 @@ - - -
- home -