From 9412dcd57793c5bfcf8cf4e7c24c1bb57b95c07e Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Tue, 25 Jul 2023 23:08:50 -0400 Subject: [PATCH] Add base virtue api --- src/config.py | 5 +++++ src/config.yaml | 3 +++ src/main.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/config.py create mode 100644 src/config.yaml create mode 100644 src/main.py diff --git a/src/config.py b/src/config.py new file mode 100644 index 0000000..2f7b66c --- /dev/null +++ b/src/config.py @@ -0,0 +1,5 @@ +from envyaml import EnvYAML +import os + +def getConfig(): + return EnvYAML(os.getenv("CONFIG", "config.yaml")) diff --git a/src/config.yaml b/src/config.yaml new file mode 100644 index 0000000..fedd0ba --- /dev/null +++ b/src/config.yaml @@ -0,0 +1,3 @@ +openapi_key: sk- +openapi_url: + diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..5b83ba1 --- /dev/null +++ b/src/main.py @@ -0,0 +1,38 @@ +from fastapi import FastAPI +import datetime + +app = FastAPI() + +ben_franklin_virtues = { + "Temperance": "Practice moderation in all things, especially eating and drinking. Don't overindulge.", + "Silence": "Speak only when it contributes to the well-being of yourself or others. Avoid unnecessary chatter.", + "Order": "Keep your personal and professional life organized. A tidy environment can lead to a tidy mind.", + "Resolution": "Be determined in your actions. If you decide to do something, follow through until it's done.", + "Frugality": "Be mindful of your spending. Save and invest wisely, and avoid unnecessary expenses.", + "Industry": "Make the most of your time. Be productive and avoid idle activities.", + "Sincerity": "Be genuine and honest in your interactions with others. Avoid deceit.", + "Justice": "Treat others fairly and justly. Don't harm others by your actions or neglect.", + "Moderation": "Avoid extremes. Be moderate in your actions and avoid holding extreme opinions.", + "Cleanliness": "Keep your body, clothes, and living spaces clean. Good hygiene and cleanliness can contribute to good health.", + "Tranquility": "Don't let minor issues upset you. Stay calm and composed, even in difficult situations.", + "Chastity": "Respect your body and the bodies of others. Engage in sexual activities responsibly and consensually.", + "Humility": "Be humble. Don't think too highly of yourself, and appreciate the value in others." +} + + +@app.get("/") +async def virtue(): + """ + Get the virtue of the week + """ + current_week = datetime.date.today().isocalendar()[1] + + virtues = list(ben_franklin_virtues.keys()) + + virtue_of_the_week = virtues[(current_week - 1) % 13] + + return { + "virtue": virtue_of_the_week, + "content": ben_franklin_virtues[virtue_of_the_week] + } +