parvalijaved commited on
Commit
ab07d1b
·
verified ·
1 Parent(s): 6786adb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -28
app.py CHANGED
@@ -18,32 +18,37 @@ st.title("Bhagavad Gita")
18
  # Fetch and display chapters and verses
19
  data = fetch_data()
20
 
21
- # Convert keys to integers for easier sorting and selection
22
- data = {int(chapter): details for chapter, details in data.items()}
23
-
24
- # Select Chapter
25
- chapter_id = st.selectbox("Select Chapter", sorted(data.keys()), format_func=lambda x: f"Chapter {x}")
26
-
27
- # Display chapter summary if available
28
- chapter_summary = data[chapter_id].get('chapter_summary', 'No summary available')
29
- st.subheader(f"Chapter {chapter_id}")
30
- st.markdown(f"**Summary:**\n\n{chapter_summary}")
31
-
32
- # Extract verses for the selected chapter
33
- verses = {verse['verse_number']: verse for verse in data[chapter_id]['verses']}
34
- verse_number = st.selectbox("Select Verse", sorted(verses.keys()))
35
-
36
- # Display selected verse
37
- selected_verse = verses[verse_number]
38
- st.markdown(f"**Verse {verse_number}**")
39
- st.markdown(f"**Sanskrit:**\n\n{selected_verse['text']}")
40
- st.markdown(f"**Translation:**\n\n{selected_verse['translation']}")
41
-
42
- # Display all verses in the selected chapter
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:** {verse['text']}")
48
- st.markdown(f"**Translation:** {verse['translation']}")
49
- st.markdown("---")
 
 
 
 
 
 
 
 
 
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("---")