diff --git a/app/app.py b/app/app.py index a735495..bcc16d9 100644 --- a/app/app.py +++ b/app/app.py @@ -25,7 +25,7 @@ DEV = int(config['NETWORK']['DEV']) MUSIC_API_TOKEN = config['AUTH']['MUSIC_API_TOKEN'] MUSIC_API_URL = config['NETWORK']['MUSIC_API_URL'] -statuses = None +statuses = {} def get_posts(category_filter : str | None = None) -> list[Post]: post_files = glob.glob(f'{POSTS_FOLDER}/*') @@ -59,21 +59,39 @@ def get_posts(category_filter : str | None = None) -> list[Post]: return reversed(ordered_posts) -def read_status_file() -> list[str]: +def read_status_file() -> dict: with open(STATUS_FILE, 'r', encoding='utf-8') as file: data = file.readlines() - result = [] + result = {} + current_key = None for line in data: - if not (line == '\n' or line[0] == '#'): - result.append(line) + if line[0] == '#': + + # Empty Key-Value pairs will cause errors + if current_key: + if not result[current_key]: + result.pop(current_key) + + current_key = line.replace('#', '').strip() + result[current_key] = [] + elif not (line == '\n'): + result[current_key].append(line) return result def get_status() -> str: - status = random.randint(0, len(statuses) - 1) + keys = list(statuses.keys()) - return markdown.markdown(statuses[status]) + selected_key = keys[random.randint(0, len(keys) - 1)] + section: list = statuses[selected_key] + + print(selected_key) + print(section) + + selected_status = section[random.randint(0, len(section) - 1)] + + return f'
{markdown.markdown(selected_status)}
' # Main Page @app.route('/') diff --git a/app/resources/status.text b/app/resources/status.text index f915d06..bff44eb 100644 --- a/app/resources/status.text +++ b/app/resources/status.text @@ -1,6 +1,4 @@ # Project Moon -Open the curtains -Don't miss a moment of this experiment Needles Sally forth Rocinante! The multitude tightens its hold. @@ -73,3 +71,22 @@ Those feelings that I had are building up to something I feel a schism in the rhythm, now I'm running My hair is liquifying My taste buds are igniting + +# Set by King Gizzard & The Lizard Wizard +Cut the cord, kill the king and reset +Squeezing day into night with supernatural pressure +Right eye is the sun and left the moon's light + +# Swan Song by King Gizzard & The Lizard Wizard +Score the music // Of your essence +Stars fall from their lofty places +Earth has been put through her paces +Cosmic surgeons cut the cable +Make a new world if you're able + +# String Theocracy by Mili +Open the curtains +Don't miss a moment of this experiment +If you're going to replace me // At least have the audacity to kill me thoroughly +What's the color of the electric sheep you see? +Maybe we're all cold machines