ashhal commited on
Commit
5365be5
·
verified ·
1 Parent(s): 8ec540a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +77 -81
app.py CHANGED
@@ -6,20 +6,22 @@ import requests
6
  from datetime import datetime
7
  from dotenv import load_dotenv
8
 
 
9
  st.set_page_config(page_title="Kalam Comfort", page_icon="📚")
10
  load_dotenv()
11
 
12
- # ---------- File Setup ----------
13
  default_moods = {
14
- "anxious": ["13:28", "2:286", "10:62", "20:46", "48:4"],
15
- "sad": ["94:5", "93:6", "65:7", "9:51", "12:86"],
16
- "hopeless": ["39:53", "12:87", "3:139", "65:2", "57:22"],
17
- "grateful": ["14:7", "31:12", "2:152", "16:114", "76:3"],
18
- "lonely": ["2:186", "9:40", "6:103", "50:16", "17:79"],
19
- "angry": ["3:134", "41:34", "7:199", "42:37", "16:126"],
20
- "lost": ["93:7", "6:122", "2:2", "24:35", "42:52"],
21
- "tired": ["94:6", "3:200", "29:69", "52:48", "6:162"],
22
- "afraid": ["8:46", "33:3", "2:286", "3:173", "11:56"]
 
23
  }
24
 
25
  default_duas = {
@@ -67,130 +69,121 @@ default_duas = {
67
  ("ربِّ أعني ولا تعن عليّ", "My Lord, support me and not against me.", "میرے رب! میری مدد فرما، میرے خلاف نہ ہو۔"),
68
  ("اللهم اجعلني من المتوكلين عليك", "O Allah, make me among those who rely on You.", "یا اللہ! مجھے اپنے اوپر بھروسہ کرنے والوں میں شامل فرما۔"),
69
  ("اللهم احفظني من بين يديّ ومن خلفي", "O Allah, protect me from in front of me and behind me.", "یا اللہ! میرے آگے پیچھے سے میری حفاظت فرما۔")
 
 
 
 
 
70
  ]
71
  }
72
 
73
-
74
  default_hadiths = {
75
  "anxious": [
76
  ("أَلَا بِذِكْرِ اللَّهِ تَطْمَئِنُّ الْقُلُوبُ", "Verily, in the remembrance of Allah do hearts find rest.", "خبردار! اللہ کے ذکر سے دلوں کو سکون ملتا ہے۔"),
77
- ("الدُّعَاءُ هُوَ العِبَادَةُ", "Dua is the essence of worship.", "دعا عبادت کا مغز ہے۔"),
78
- ("إِذَا سَأَلْتَ فَاسْأَلِ اللَّهَ", "When you ask, ask Allah.", "جب مانگو تو اللہ سے مانگو۔")
79
  ],
80
  "sad": [
81
  ("إِنَّ مَعَ الْعُسْرِ يُسْرًا", "Indeed, with hardship comes ease.", "بیشک ہر تنگی کے ساتھ آسانی ہے۔"),
82
- ("لَا يُكَلِّفُ اللَّهُ نَفْسًا إِلَّا وُسْعَهَا", "Allah does not burden a soul beyond its capacity.", "اللہ کسی جان پر اس کی طاقت سے زیادہ بوجھ نہیں ڈالتا۔"),
83
- ("وَعَسَى أَنْ تَكْرَهُوا شَيْئًا وَهُوَ خَيْرٌ لَكُمْ", "You may dislike a thing that is good for you.", "ہوسکتا ہے تم کسی چیز کو ناپسند کرو جو تمہارے لیے بہتر ہو۔")
84
  ],
85
  "hopeless": [
86
  ("مَن تَوَكَّلَ عَلَى اللَّهِ فَهُوَ حَسْبُهُ", "Whoever relies upon Allah — He is sufficient for him.", "جو اللہ پر بھروسہ کرے، وہ اس کے لیے کافی ہے۔"),
87
- ("وَمَنْ يَتَّقِ اللَّهَ يَجْعَلْ لَهُ مَخْرَجًا", "Whoever fears Allah, He will make for him a way out.", "جو اللہ سے ڈرے، اللہ اس کے لیے راستہ پیدا کر دیتا ہے۔"),
88
- ("إِنَّ رَحْمَتِي سَبَقَتْ غَضَبِي", "Indeed, My mercy prevails over My wrath.", "یقیناً میری رحمت میرے غضب پر غالب ہے۔")
89
  ],
90
  "grateful": [
91
  ("مَن لَا يَشْكُرُ النَّاسَ لَا يَشْكُرُ اللَّهَ", "He who does not thank people does not thank Allah.", "جو لوگوں کا شکر ادا نہیں کرتا، وہ اللہ کا بھی شکر نہیں کرتا۔"),
92
- ("إِنَّ اللَّهَ يُحِبُّ الشَّاكِرِينَ", "Indeed, Allah loves the grateful.", "اللہ شکر گزاروں سے محبت کرتا ہے۔"),
93
- ("وَلَئِن شَكَرْتُمْ لَأَزِيدَنَّكُمْ", "If you are grateful, I will surely increase you.", "اگر تم شکر ادا کرو گے تو میں تمہیں ضرور بڑھاؤں گا۔")
94
  ],
95
  "lonely": [
96
  ("أَنَا أَوْلَى بِالْمُؤْمِنِينَ مِنْ أَنْفُسِهِمْ", "I am closer to the believers than their own selves.", "میں مومنوں سے ان کی اپنی جانوں سے بھی زیادہ قریب ہوں۔"),
97
- ("إِنِّي مَعَكُمَا أَسْمَعُ وَأَرَى", "Indeed, I am with you both; I hear and I see.", "بیشک میں تم دونوں کے ساتھ ہوں، میں سنتا اور دیکھتا ہوں۔"),
98
- ("وَهُوَ مَعَكُمْ أَيْنَ مَا كُنتُمْ", "And He is with you wherever you are.", "اور وہ تمہارے ساتھ ہے جہاں بھی تم ہو۔")
99
  ],
100
  "angry": [
101
- ("لَيْسَ الشَّدِيدُ بِالصُّرَعَةِ...", "The strong man is not the one who wrestles, but controls himself in anger.", "طاقتور وہ نہیں جو پچھاڑ دے، بلکہ وہ ہے جو غصے میں خود پر قابو رکھے۔"),
102
- ("إِذَا غَضِبَ أَحَدُكُمْ فَلْيَسْكُتْ", "When one of you is angry, let him remain silent.", "جب تم میں سے کوئی غصے میں ہو، تو خاموش رہے۔"),
103
- ("لَا تَغْضَبْ", "Do not get angry.", "غصہ نہ کرو۔")
104
  ],
105
  "lost": [
106
- ("مَنْ سَلَكَ طَرِيقًا يَلْتَمِسُ فِيهِ عِلْمًا...", "Whoever seeks a path in search of knowledge, Allah will ease his path to Paradise.", "جو علم کے راستے پر چلے، اللہ اس کے لیے جنت کا راستہ آسان کر دیتا ہے۔"),
107
- ("إِنَّ هَذَا الْقُرْآنَ يَهْدِي", "Indeed, this Quran guides.", "بیشک یہ قرآن ہدایت دیتا ہے۔"),
108
- ("وَإِنَّكَ لَتَهْدِي إِلَىٰ صِرَاطٍ مُّسْتَقِيمٍ", "And indeed, you guide to the straight path.", "اور بیشک تم سیدھے راستے کی طرف رہنمائی کرتے ہو۔")
109
  ],
110
  "tired": [
111
- ("مَا يُصِيبُ الْمُسْلِمَ مِنْ نَصَبٍ...", "No fatigue or disease affects a Muslim except that Allah removes sins.", "مسلمان کو جو بھی تھکن یا مرض لاحق ہو، اللہ اس سے اس کے گناہ مٹا دیتا ہے۔"),
112
- ("وَاصْبِرْ وَمَا صَبْرُكَ إِلَّا بِاللَّهِ", "Be patient, and your patience is not but through Allah.", "صبر کرو، اور تمہارا صبر اللہ ہی کی مدد سے ہے۔"),
113
- ("وَتَوَكَّلْ عَلَى الْحَيِّ الَّذِي لَا يَمُوتُ", "And rely upon the Ever-Living who does not die.", "اور اُس زندہ ذات پر بھروسہ کرو جو کبھی نہیں مرے گا۔")
114
  ],
115
  "afraid": [
116
- ("احْفَظِ اللَّهَ يَحْفَظْكَ", "Be mindful of Allah, He will protect you.", "اللہ کا دھیان رکھو، وہ تمہاری حفاظت کرے گا۔"),
117
- ("فَإِنَّ مَعِيَ رَبِّي سَيَهْدِينِ", "Indeed, my Lord is with me; He will guide me.", "میرا رب میرے ساتھ ہے، وہ مجھے راستہ دکھائے گا۔"),
118
- ("لَا خَوْفٌ عَلَيْهِمْ وَلَا هُمْ يَحْزَنُونَ", "No fear will be upon them, nor will they grieve.", "نہ ان پر کوئی خوف ہوگا اور نہ وہ غمگین ہوں گے۔")
 
 
 
 
 
119
  ]
120
  }
121
 
122
 
123
- # File creation if missing
124
  if not os.path.exists("moods.json"):
125
  with open("moods.json", "w") as f:
126
  json.dump(default_moods, f, indent=4)
127
-
128
  if not os.path.exists("reflections.json"):
129
  with open("reflections.json", "w") as f:
130
- json.dump({}, f)
131
 
132
- # Load data
133
- with open("moods.json", "r") as f:
134
  moods = json.load(f)
135
- with open("reflections.json", "r") as f:
136
  reflections = json.load(f)
137
 
138
- # ---------- UI ----------
139
  st.title("📚 Kalam Comfort")
140
  st.subheader("Find Quranic comfort by emotion 💖")
141
 
142
  selected_mood = st.selectbox("How are you feeling today?", list(moods.keys()), index=0)
143
 
144
- if st.button("🔁 Show another verse"):
145
- st.rerun()
146
-
147
  if selected_mood:
148
- # ----------- Quranic Verse -----------
149
- verse_list = moods[selected_mood]
150
- verse_ref = random.choice(verse_list)
151
- surah_num, ayah_num = verse_ref.split(":")
152
-
153
- quran_api = f"https://api.alquran.cloud/v1/ayah/{surah_num}:{ayah_num}/editions/quran-simple,en.asad,ur.jalandhry"
154
- response = requests.get(quran_api)
155
 
156
  if response.status_code == 200:
157
- data = response.json()['data']
158
- arabic = data[0]['text']
159
- english = data[1]['text']
160
- urdu = data[2]['text']
161
- surah_info = f"{data[0]['surah']['englishName']} ({data[0]['surah']['name']})"
162
-
163
  st.markdown("### 🌙 Quranic Verse")
164
- st.markdown(f"**Surah:** {surah_info} — Ayah {ayah_num}")
165
- st.markdown(f"<div style='font-size:24px; direction: rtl'>{arabic}</div>", unsafe_allow_html=True)
166
- st.markdown(f"**📖 English:** *{english}*")
167
- st.markdown(f"**📖 Urdu:** {urdu}")
168
  else:
169
- st.error("Failed to fetch Quranic verse.")
170
- st.stop()
171
 
172
- # ---------- Dua ----------
173
  st.markdown("### 🤲 Dua")
174
- if selected_mood in default_duas:
175
- dua_ar, dua_en, dua_ur = random.choice(default_duas[selected_mood])
176
- st.markdown(f"<div style='font-size:22px; direction: rtl'>{dua_ar}</div>", unsafe_allow_html=True)
177
- st.markdown(f"**English:** {dua_en}")
178
- st.markdown(f"**Urdu:** {dua_ur}")
179
-
180
- # ---------- Hadith ----------
181
- st.markdown("### 🌟 Hadith")
182
  if selected_mood in default_hadiths:
183
- had_ar, had_en, had_ur = random.choice(default_hadiths[selected_mood])
184
- st.markdown(f"<div style='font-size:20px; direction: rtl'>{had_ar}</div>", unsafe_allow_html=True)
185
- st.markdown(f"**English:** {had_en}")
186
- st.markdown(f"**Urdu:** {had_ur}")
187
-
188
- # ---------- Reflection ----------
189
- st.markdown("### 📝 Your Reflection")
190
- reflection_input = st.text_area("Write your thoughts:", placeholder="How does this verse speak to you today?")
191
  if st.button("💾 Save Reflection"):
192
  reflections[selected_mood] = {
193
- "text": reflection_input,
194
  "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M")
195
  }
196
  with open("reflections.json", "w") as f:
@@ -199,5 +192,8 @@ if selected_mood:
199
 
200
  if selected_mood in reflections:
201
  last = reflections[selected_mood]
202
- st.markdown("#### 📜 Last Saved Reflection:")
203
  st.markdown(f"**{last['timestamp']}** — {last['text']}")
 
 
 
 
6
  from datetime import datetime
7
  from dotenv import load_dotenv
8
 
9
+ # --- Streamlit Config ---
10
  st.set_page_config(page_title="Kalam Comfort", page_icon="📚")
11
  load_dotenv()
12
 
13
+ # --- Default Mappings ---
14
  default_moods = {
15
+ "anxious": ["13:28", "2:286", "10:62"],
16
+ "sad": ["94:5", "93:6", "65:7"],
17
+ "hopeless": ["39:53", "12:87", "3:139"],
18
+ "grateful": ["14:7", "31:12"],
19
+ "lonely": ["2:186", "9:40"],
20
+ "angry": ["3:134", "41:34"],
21
+ "lost": ["93:7", "6:122"],
22
+ "tired": ["94:6", "3:200"],
23
+ "afraid": ["8:46", "33:3"],
24
+ "happy": ["16:18", "28:70", "55:13"]
25
  }
26
 
27
  default_duas = {
 
69
  ("ربِّ أعني ولا تعن عليّ", "My Lord, support me and not against me.", "میرے رب! میری مدد فرما، میرے خلاف نہ ہو۔"),
70
  ("اللهم اجعلني من المتوكلين عليك", "O Allah, make me among those who rely on You.", "یا اللہ! مجھے اپنے اوپر بھروسہ کرنے والوں میں شامل فرما۔"),
71
  ("اللهم احفظني من بين يديّ ومن خلفي", "O Allah, protect me from in front of me and behind me.", "یا اللہ! میرے آگے پیچھے سے میری حفاظت فرما۔")
72
+ ],
73
+ "happy": [
74
+ ("اللهم اجعل سعادتي دائمة", "O Allah, make my happiness everlasting.", "یا اللہ! میری خوشی کو دائمی بنا دے۔"),
75
+ ("اللهم كما أسعدتني فأسعد قلبي دومًا بذكرك", "O Allah, as You made me happy, keep my heart joyful with Your remembrance.", "یا اللہ! جیسے تو نے مجھے خوشی دی، ویسے ہی اپنے ذکر سے میرے دل کو ہمیشہ خوش رکھ۔"),
76
+ ("اللهم بارك لي في نعمك ولا تجعلني من الغافلين", "O Allah, bless me in Your blessings and don’t make me among the heedless.", "یا اللہ! اپنی نعمتوں میں برکت عطا فرما اور مجھے غافلوں میں سے نہ بنا۔")
77
  ]
78
  }
79
 
 
80
  default_hadiths = {
81
  "anxious": [
82
  ("أَلَا بِذِكْرِ اللَّهِ تَطْمَئِنُّ الْقُلُوبُ", "Verily, in the remembrance of Allah do hearts find rest.", "خبردار! اللہ کے ذکر سے دلوں کو سکون ملتا ہے۔"),
83
+ ("إِذَا سَأَلْتَ فَاسْأَلِ اللَّهَ", "If you ask, ask Allah.", "اگر سوال کرو تو اللہ سے کرو۔"),
84
+ ("اللَّهُ أَرْحَمُ بِعِبَادِهِ", "Allah is more merciful to His slaves than a mother to her child.", "اللہ اپنے بندوں پر ماں سے بھی زیادہ رحم کرنے والا ہے۔")
85
  ],
86
  "sad": [
87
  ("إِنَّ مَعَ الْعُسْرِ يُسْرًا", "Indeed, with hardship comes ease.", "بیشک ہر تنگی کے ساتھ آسانی ہے۔"),
88
+ ("لَا يَحْزُنكَ قَوْلُهُمْ", "Let not their words grieve you.", "ان کی باتیں آپ کو غمگین نہ کریں۔"),
89
+ ("لَا تَحْزَنْ إِنَّ اللَّهَ مَعَنَا", "Do not grieve, indeed Allah is with us.", "غم نہ کرو، بے شک اللہ ہمارے ساتھ ہے۔")
90
  ],
91
  "hopeless": [
92
  ("مَن تَوَكَّلَ عَلَى اللَّهِ فَهُوَ حَسْبُهُ", "Whoever relies upon Allah — He is sufficient for him.", "جو اللہ پر بھروسہ کرے، وہ اس کے لیے کافی ہے۔"),
93
+ ("إِنَّهُ لَا يَيْأَسُ مِنْ رَوْحِ اللَّهِ", "None despairs of Allah's mercy except the disbelieving people.", "اللہ کی رحمت سے صرف کافر ہی ناامید ہوتے ہیں۔"),
94
+ ("وَرَحْمَتِي وَسِعَتْ كُلَّ شَيْءٍ", "My mercy encompasses all things.", "میری رحمت ہر چیز کو محیط ہے۔")
95
  ],
96
  "grateful": [
97
  ("مَن لَا يَشْكُرُ النَّاسَ لَا يَشْكُرُ اللَّهَ", "He who does not thank people does not thank Allah.", "جو لوگوں کا شکر ادا نہیں کرتا، وہ اللہ کا بھی شکر نہیں کرتا۔"),
98
+ ("اللَّهُ يُحِبُّ الشَّاكِرِينَ", "Allah loves those who are grateful.", "اللہ شکر گزاروں سے محبت کرتا ہے۔"),
99
+ ("وَاشْكُرُوا لِي وَلَا تَكْفُرُونِ", "Be thankful to Me and do not deny Me.", "میرا شکر ادا کرو اور ناشکری نہ کرو۔")
100
  ],
101
  "lonely": [
102
  ("أَنَا أَوْلَى بِالْمُؤْمِنِينَ مِنْ أَنْفُسِهِمْ", "I am closer to the believers than their own selves.", "میں مومنوں سے ان کی اپنی جانوں سے بھی زیادہ قریب ہوں۔"),
103
+ ("إِنِّي مَعَكُمَا أَسْمَعُ وَأَرَى", "Indeed, I am with you both; I hear and see.", "بے شک میں تم دونوں کے ساتھ ہوں، میں سنتا اور دیکھتا ہوں۔"),
104
+ ("اللَّهُ وَلِيُّ الَّذِينَ آمَنُوا", "Allah is the protector of those who believe.", "اللہ ایمان والوں کا ولی ہے۔")
105
  ],
106
  "angry": [
107
+ ("لَيْسَ الشَّدِيدُ بِالصُّرَعَةِ...", "The strong is not the one who overcomes others in wrestling but the one who controls himself in anger.", "طاقتور وہ نہیں جو پچھاڑ دے، بلکہ وہ ہے جو غصے میں خود پر قابو رکھے۔"),
108
+ ("لَا تَغْضَبْ", "Do not become angry.", "غصہ نہ کرو۔"),
109
+ ("وَإِذَا مَا غَضِبُوا هُمْ يَغْفِرُونَ", "When they are angry, they forgive.", "جب وہ غصے میں ہوتے ہیں تو معاف کر دیتے ہیں۔")
110
  ],
111
  "lost": [
112
+ ("مَنْ سَلَكَ طَرِيقًا يَلْتَمِسُ فِيهِ عِلْمًا...", "Whoever treads a path in search of knowledge, Allah makes his path to Paradise easy.", "جو علم کے راستے پر چلے، اللہ اس کے لیے جنت کا راستہ آسان کر دیتا ہے۔"),
113
+ ("وَوَجَدَكَ ضَالًّا فَهَدَى", "And He found you lost and guided [you].", "اور اُس نے آپ کو بھٹکا ہوا پایا، تو راہ دکھائی۔"),
114
+ ("اللَّهُ نُورُ السَّمَاوَاتِ وَالْأَرْضِ", "Allah is the Light of the heavens and the earth.", "اللہ آسمانوں اور زمین کا نور ہے۔")
115
  ],
116
  "tired": [
117
+ ("مَا يُصِيبُ الْمُسْلِمَ مِنْ نَصَبٍ...", "No fatigue afflicts a Muslim except that Allah removes sins thereby.", "مسلمان کو جو بھی تھکن یا مرض لاحق ہو، اللہ اس سے اس کے گناہ مٹا دیتا ہے۔"),
118
+ ("وَاصْبِرْ وَمَا صَبْرُكَ إِلَّا بِاللَّهِ", "And be patient, and your patience is not but through Allah.", "صبر کرو، اور تمہارا صبر صرف اللہ کے لیے ہے۔"),
119
+ ("إِنَّ مَعَ الْعُسْرِ يُسْرًا", "Indeed, with hardship comes ease.", "بے شک تنگی کے ساتھ آسانی ہے۔")
120
  ],
121
  "afraid": [
122
+ ("احْفَظِ اللَّهَ يَحْفَظْكَ", "Be mindful of Allah and He will protect you.", "اللہ کا دھیان رکھو، وہ تمہاری حفاظت کرے گا۔"),
123
+ ("لَا خَوْفٌ عَلَيْهِمْ وَلَا هُمْ يَحْزَنُونَ", "No fear will there be concerning them, nor will they grieve.", "ان پر نہ کوئی خوف ہوگا اور نہ وہ غمگین ہوں گے۔"),
124
+ ("إِنَّ اللَّهَ مَعَ الَّذِينَ اتَّقَوْا", "Indeed, Allah is with those who fear Him.", "بے شک اللہ پرہیزگاروں کے ساتھ ہے۔")
125
+ ],
126
+ "happy": [
127
+ ("الْفَرَحُ نِعْمَةٌ مِنَ اللَّهِ", "Happiness is a blessing from Allah.", "خوشی اللہ کی طرف سے ایک نعمت ہے۔"),
128
+ ("تَبَسُّمُكَ فِي وَجْهِ أَخِيكَ صَدَقَةٌ", "Smiling in the face of your brother is charity.", "اپنے بھائی کے چہرے پر مسکرانا صدقہ ہے۔"),
129
+ ("إِنَّ اللَّهَ يُحِبُّ الْفَرَحِينَ بِطَاعَتِهِ", "Indeed, Allah loves those who rejoice in His obedience.", "بیشک اللہ ان لوگوں سے محبت کرتا ہے جو اس کی اطاعت میں خوش ہوتے ہیں۔")
130
  ]
131
  }
132
 
133
 
134
+ # --- Initial File Setup ---
135
  if not os.path.exists("moods.json"):
136
  with open("moods.json", "w") as f:
137
  json.dump(default_moods, f, indent=4)
 
138
  if not os.path.exists("reflections.json"):
139
  with open("reflections.json", "w") as f:
140
+ json.dump({}, f, indent=4)
141
 
142
+ with open("moods.json") as f:
 
143
  moods = json.load(f)
144
+ with open("reflections.json") as f:
145
  reflections = json.load(f)
146
 
147
+ # --- UI ---
148
  st.title("📚 Kalam Comfort")
149
  st.subheader("Find Quranic comfort by emotion 💖")
150
 
151
  selected_mood = st.selectbox("How are you feeling today?", list(moods.keys()), index=0)
152
 
 
 
 
153
  if selected_mood:
154
+ verse_ref = random.choice(moods[selected_mood])
155
+ surah, ayah = verse_ref.split(":")
156
+ url = f"https://api.alquran.cloud/v1/ayah/{surah}:{ayah}/editions/quran-simple,en.asad,ur.jalandhry"
157
+ response = requests.get(url)
 
 
 
158
 
159
  if response.status_code == 200:
160
+ data = response.json()["data"]
 
 
 
 
 
161
  st.markdown("### 🌙 Quranic Verse")
162
+ st.markdown(f"**Surah:** {data[0]['surah']['englishName']} — Ayah {ayah}")
163
+ st.markdown(f"<div style='font-size:24px; direction: rtl'>{data[0]['text']}</div>", unsafe_allow_html=True)
164
+ st.markdown(f"**📖 English:** *{data[1]['text']}*")
165
+ st.markdown(f"**📖 Urdu:** {data[2]['text']}")
166
  else:
167
+ st.error("Failed to fetch Quranic verse.")
 
168
 
 
169
  st.markdown("### 🤲 Dua")
170
+ dua = random.choice(default_duas[selected_mood])
171
+ st.markdown(f"**Arabic:** {dua[0]}")
172
+ st.markdown(f"**English:** *{dua[1]}*")
173
+ st.markdown(f"**Urdu:** {dua[2]}")
174
+
 
 
 
175
  if selected_mood in default_hadiths:
176
+ hadith = random.choice(default_hadiths[selected_mood])
177
+ st.markdown("### 📜 Hadith")
178
+ st.markdown(f"**Arabic:** {hadith[0]}")
179
+ st.markdown(f"**English:** *{hadith[1]}*")
180
+ st.markdown(f"**Urdu:** {hadith[2]}")
181
+
182
+ st.markdown("### 📝 Reflection")
183
+ reflection = st.text_area("Write your reflection:")
184
  if st.button("💾 Save Reflection"):
185
  reflections[selected_mood] = {
186
+ "text": reflection,
187
  "timestamp": datetime.now().strftime("%Y-%m-%d %H:%M")
188
  }
189
  with open("reflections.json", "w") as f:
 
192
 
193
  if selected_mood in reflections:
194
  last = reflections[selected_mood]
195
+ st.markdown("#### 📄 Last Reflection")
196
  st.markdown(f"**{last['timestamp']}** — {last['text']}")
197
+
198
+ if st.button("🔁 Show another"):
199
+ st.rerun()