import streamlit as st from data import storiesDb import constants as C import utils as U st.set_page_config( page_title="Popular Stories Databse", page_icon=C.AI_ICON, # menu_items={"About": None} ) U.applyCommonStyles() st.markdown( """ """, unsafe_allow_html=True ) st.subheader("Choose a popular story") storyPlaceholder = st.empty() col1, col2, col3 = storyPlaceholder.columns([1.5, 2.2, 1.5]) col2.image(C.DB_LOADER) col2.write( """
Loading from database ...
""", unsafe_allow_html=True ) if "dbStories" not in st.session_state: st.session_state.dbStories = storiesDb.getAllStories() with storyPlaceholder.container(border=False, height=500): for idx, story in enumerate(st.session_state.dbStories): storyTitle = story['Story Title'] storyDetails = story['Story Text'] with st.expander(storyTitle): st.markdown(storyDetails) if st.button( "Select", key=f"select_{idx}", type="primary", use_container_width=True ): U.pprint(f"Selected story: {storyTitle}") st.session_state.isStoryChosen = True st.session_state.selectedStoryTitle = storyTitle st.session_state.selectedStory = { "title": storyTitle, "text": storyDetails } st.switch_page("app.py")