Spaces:
Sleeping
Sleeping
parvalijaved
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -18,37 +18,35 @@ st.title("Bhagavad Gita")
|
|
18 |
# Fetch and display chapters and verses
|
19 |
data = fetch_data()
|
20 |
|
21 |
-
#
|
22 |
if isinstance(data, list):
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
st.markdown(f"**Verse {verse_number}**")
|
44 |
-
st.markdown(f"**Sanskrit
|
45 |
-
st.markdown(f"**Translation
|
46 |
-
|
47 |
-
# Display all verses in the selected chapter
|
48 |
-
st.subheader("All Verses in this Chapter")
|
49 |
-
for verse_number in sorted(verses.keys()):
|
50 |
-
verse = verses[verse_number]
|
51 |
-
st.markdown(f"**Verse {verse_number}**")
|
52 |
-
st.markdown(f"**Sanskrit:** {verse['text']}")
|
53 |
-
st.markdown(f"**Translation:** {verse['translation']}")
|
54 |
-
st.markdown("---")
|
|
|
18 |
# Fetch and display chapters and verses
|
19 |
data = fetch_data()
|
20 |
|
21 |
+
# Check the type of data and parse accordingly
|
22 |
if isinstance(data, list):
|
23 |
+
chapters = {int(chapter["chapter_number"]): chapter for chapter in data}
|
24 |
+
else: # Assuming data is a dictionary
|
25 |
+
chapters = {int(chapter_number): details for chapter_number, details in data.items()}
|
26 |
+
|
27 |
+
# Select Chapter
|
28 |
+
chapter_id = st.selectbox("Select Chapter", sorted(chapters.keys()), format_func=lambda x: f"Chapter {x}")
|
29 |
+
|
30 |
+
# Display chapter summary if available
|
31 |
+
chapter_summary = chapters[chapter_id].get('chapter_summary', 'No summary available')
|
32 |
+
st.subheader(f"Chapter {chapter_id}")
|
33 |
+
st.markdown(f"**Summary:**\n\n{chapter_summary}")
|
34 |
+
|
35 |
+
# Extract verses for the selected chapter
|
36 |
+
verses = {verse['verse_number']: verse for verse in chapters[chapter_id]['verses']}
|
37 |
+
verse_number = st.selectbox("Select Verse", sorted(verses.keys()))
|
38 |
+
|
39 |
+
# Display selected verse
|
40 |
+
selected_verse = verses[verse_number]
|
41 |
+
st.markdown(f"**Verse {verse_number}**")
|
42 |
+
st.markdown(f"**Sanskrit:**\n\n{selected_verse['text']}")
|
43 |
+
st.markdown(f"**Translation:**\n\n{selected_verse['translation']}")
|
44 |
+
|
45 |
+
# Display all verses in the selected chapter
|
46 |
+
st.subheader("All Verses in this Chapter")
|
47 |
+
for verse_number in sorted(verses.keys()):
|
48 |
+
verse = verses[verse_number]
|
49 |
st.markdown(f"**Verse {verse_number}**")
|
50 |
+
st.markdown(f"**Sanskrit:** {verse['text']}")
|
51 |
+
st.markdown(f"**Translation:** {verse['translation']}")
|
52 |
+
st.markdown("---")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|