Spaces:
Sleeping
Sleeping
parvalijaved
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -18,32 +18,37 @@ st.title("Bhagavad Gita")
|
|
18 |
# Fetch and display chapters and verses
|
19 |
data = fetch_data()
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
st.
|
31 |
-
|
32 |
-
#
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
st.
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
st.subheader("All Verses in this Chapter")
|
44 |
-
for verse_number in sorted(verses.keys()):
|
45 |
-
verse = verses[verse_number]
|
46 |
st.markdown(f"**Verse {verse_number}**")
|
47 |
-
st.markdown(f"**Sanskrit
|
48 |
-
st.markdown(f"**Translation
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# Fetch and display chapters and verses
|
19 |
data = fetch_data()
|
20 |
|
21 |
+
# Ensure data is correctly structured
|
22 |
+
if isinstance(data, list):
|
23 |
+
st.error("JSON data structure is not as expected. Please check the JSON file structure.")
|
24 |
+
|
25 |
+
else:
|
26 |
+
# Convert keys to integers for easier sorting and selection
|
27 |
+
data = {int(chapter): details for chapter, details in data.items()}
|
28 |
+
|
29 |
+
# Select Chapter
|
30 |
+
chapter_id = st.selectbox("Select Chapter", sorted(data.keys()), format_func=lambda x: f"Chapter {x}")
|
31 |
+
|
32 |
+
# Display chapter summary if available
|
33 |
+
chapter_summary = data[chapter_id].get('chapter_summary', 'No summary available')
|
34 |
+
st.subheader(f"Chapter {chapter_id}")
|
35 |
+
st.markdown(f"**Summary:**\n\n{chapter_summary}")
|
36 |
+
|
37 |
+
# Extract verses for the selected chapter
|
38 |
+
verses = {verse['verse_number']: verse for verse in data[chapter_id]['verses']}
|
39 |
+
verse_number = st.selectbox("Select Verse", sorted(verses.keys()))
|
40 |
+
|
41 |
+
# Display selected verse
|
42 |
+
selected_verse = verses[verse_number]
|
|
|
|
|
|
|
43 |
st.markdown(f"**Verse {verse_number}**")
|
44 |
+
st.markdown(f"**Sanskrit:**\n\n{selected_verse['text']}")
|
45 |
+
st.markdown(f"**Translation:**\n\n{selected_verse['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("---")
|