Spaces:
Runtime error
Runtime error
shravya commited on
Commit ·
1e80d50
1
Parent(s): 888953a
added multipage navigation
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ def icon(emoji: str):
|
|
| 20 |
)
|
| 21 |
|
| 22 |
|
| 23 |
-
st.set_page_config(layout="wide")
|
| 24 |
|
| 25 |
|
| 26 |
def main():
|
|
@@ -94,6 +94,7 @@ def main():
|
|
| 94 |
st.markdown(f"**Reason For Recommendation:** {article.get('reason_for_recommendation', '')}")
|
| 95 |
st.markdown("---")
|
| 96 |
|
| 97 |
-
|
|
|
|
| 98 |
if __name__ == "__main__":
|
| 99 |
main()
|
|
|
|
| 20 |
)
|
| 21 |
|
| 22 |
|
| 23 |
+
# st.set_page_config(layout="wide")
|
| 24 |
|
| 25 |
|
| 26 |
def main():
|
|
|
|
| 94 |
st.markdown(f"**Reason For Recommendation:** {article.get('reason_for_recommendation', '')}")
|
| 95 |
st.markdown("---")
|
| 96 |
|
| 97 |
+
if st.sidebar.button("← Back to Main Page"):
|
| 98 |
+
st.session_state.page = "main"
|
| 99 |
if __name__ == "__main__":
|
| 100 |
main()
|
main.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
load_dotenv()
|
| 4 |
+
from streamlit_extras.stylable_container import stylable_container
|
| 5 |
+
|
| 6 |
+
from app import main as article_recommendor_main
|
| 7 |
+
from research_paper import main as research_article_suggester_main
|
| 8 |
+
from test import main as feedback_main
|
| 9 |
+
|
| 10 |
+
st.set_page_config(page_title='Multi-Page App', page_icon='📰', layout='wide')
|
| 11 |
+
|
| 12 |
+
def main():
|
| 13 |
+
if 'page' not in st.session_state:
|
| 14 |
+
st.session_state.page = "main"
|
| 15 |
+
|
| 16 |
+
if st.session_state.page == "main":
|
| 17 |
+
show_main_page()
|
| 18 |
+
elif st.session_state.page == "article_recommendor":
|
| 19 |
+
article_recommendor_main()
|
| 20 |
+
elif st.session_state.page == "research_article_suggester":
|
| 21 |
+
research_article_suggester_main()
|
| 22 |
+
elif st.session_state.page == "feedback":
|
| 23 |
+
feedback_main()
|
| 24 |
+
|
| 25 |
+
def show_main_page():
|
| 26 |
+
st.markdown(
|
| 27 |
+
"""
|
| 28 |
+
<style>
|
| 29 |
+
body {
|
| 30 |
+
background-color: #2e2e2e;
|
| 31 |
+
background-size: cover;
|
| 32 |
+
background-position: center;
|
| 33 |
+
background-repeat: no-repeat;
|
| 34 |
+
}
|
| 35 |
+
.main-title {
|
| 36 |
+
font-size: 3em;
|
| 37 |
+
font-weight: bold;
|
| 38 |
+
margin-top: 20px;
|
| 39 |
+
text-align: center;
|
| 40 |
+
}
|
| 41 |
+
.sub-header {
|
| 42 |
+
font-size: 1.5em;
|
| 43 |
+
margin: 20px 0;
|
| 44 |
+
text-align: center;
|
| 45 |
+
}
|
| 46 |
+
.card {
|
| 47 |
+
|
| 48 |
+
border-radius: 10px;
|
| 49 |
+
padding: 20px;
|
| 50 |
+
width: 300px;
|
| 51 |
+
height: 300px;
|
| 52 |
+
text-align: center;
|
| 53 |
+
margin: 20px;
|
| 54 |
+
}
|
| 55 |
+
.card-button {
|
| 56 |
+
background-color: #ff4b4b;
|
| 57 |
+
color: white;
|
| 58 |
+
border: none;
|
| 59 |
+
padding: 10px 20px;
|
| 60 |
+
font-size: 1em;
|
| 61 |
+
border-radius: 5px;
|
| 62 |
+
cursor: pointer;
|
| 63 |
+
}
|
| 64 |
+
.card-button:hover {
|
| 65 |
+
background-color: #ff7979;
|
| 66 |
+
}
|
| 67 |
+
</style>
|
| 68 |
+
""", unsafe_allow_html=True)
|
| 69 |
+
|
| 70 |
+
st.markdown('<div class="main-title">Welcome to the Multi-Page App!</div>', unsafe_allow_html=True)
|
| 71 |
+
st.markdown("---")
|
| 72 |
+
st.markdown('<div class="sub-header">Navigate to Specific Pages:</div>', unsafe_allow_html=True)
|
| 73 |
+
|
| 74 |
+
card_info = [
|
| 75 |
+
{"title": "Article Recommendor", "description": "Discover articles tailored to your interests.", "key": "article_recommendor"},
|
| 76 |
+
{"title": "Recent Article Suggester", "description": "Get suggestions for recent research articles.", "key": "research_article_suggester"},
|
| 77 |
+
{"title": "Feedback", "description": "Provide your valuable feedback.", "key": "feedback"},
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
]
|
| 81 |
+
|
| 82 |
+
num_cols = 3
|
| 83 |
+
num_rows = (len(card_info) + num_cols - 1) // num_cols
|
| 84 |
+
|
| 85 |
+
with stylable_container(
|
| 86 |
+
key="container_with_border",
|
| 87 |
+
css_styles="""
|
| 88 |
+
{
|
| 89 |
+
display: flex;
|
| 90 |
+
# justify-content: center;
|
| 91 |
+
align-items: center;
|
| 92 |
+
flex-wrap: wrap;
|
| 93 |
+
}
|
| 94 |
+
""",
|
| 95 |
+
):
|
| 96 |
+
|
| 97 |
+
for row in range(num_rows):
|
| 98 |
+
cols = st.columns(num_cols)
|
| 99 |
+
for col in range(num_cols):
|
| 100 |
+
index = row * num_cols + col
|
| 101 |
+
if index < len(card_info):
|
| 102 |
+
card = card_info[index]
|
| 103 |
+
with cols[col]:
|
| 104 |
+
with stylable_container(
|
| 105 |
+
key="inside_container_with_border",
|
| 106 |
+
css_styles="""
|
| 107 |
+
{
|
| 108 |
+
border-radius: 10px;
|
| 109 |
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
|
| 110 |
+
align-items: center;
|
| 111 |
+
flex-wrap: wrap;
|
| 112 |
+
padding:10px;
|
| 113 |
+
}
|
| 114 |
+
""",
|
| 115 |
+
):
|
| 116 |
+
st.markdown(
|
| 117 |
+
f'''
|
| 118 |
+
<div class="card">
|
| 119 |
+
<h2>{card["title"]}</h2>
|
| 120 |
+
<p>{card["description"]}</p>
|
| 121 |
+
|
| 122 |
+
</div>
|
| 123 |
+
''', unsafe_allow_html=True)
|
| 124 |
+
|
| 125 |
+
if st.button(f"Go to {card['title']}", key=card["key"]):
|
| 126 |
+
st.session_state.page = card["key"]
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
if __name__ == '__main__':
|
| 130 |
+
main()
|
research_paper.py
CHANGED
|
@@ -2,9 +2,11 @@ import streamlit as st
|
|
| 2 |
from crew.research_article_suggester import RecentArticleSuggester
|
| 3 |
from streamlit_extras.capture import stdout
|
| 4 |
|
| 5 |
-
def main():
|
| 6 |
-
st.set_page_config(page_title='Recent Article Suggester', page_icon='📰', layout='wide')
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
st.markdown(
|
| 9 |
"""
|
| 10 |
<style>
|
|
@@ -125,6 +127,7 @@ def main():
|
|
| 125 |
""",
|
| 126 |
unsafe_allow_html=True
|
| 127 |
)
|
| 128 |
-
|
|
|
|
| 129 |
if __name__ == "__main__":
|
| 130 |
main()
|
|
|
|
| 2 |
from crew.research_article_suggester import RecentArticleSuggester
|
| 3 |
from streamlit_extras.capture import stdout
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
# st.set_page_config(page_title='Recent Article Suggester', page_icon='📰', layout='wide')
|
| 7 |
+
|
| 8 |
+
def main():
|
| 9 |
+
|
| 10 |
st.markdown(
|
| 11 |
"""
|
| 12 |
<style>
|
|
|
|
| 127 |
""",
|
| 128 |
unsafe_allow_html=True
|
| 129 |
)
|
| 130 |
+
if st.sidebar.button("← Back to Main Page"):
|
| 131 |
+
st.session_state.page = "main"
|
| 132 |
if __name__ == "__main__":
|
| 133 |
main()
|
test.py
CHANGED
|
@@ -13,8 +13,8 @@ from streamlit_extras.capture import stdout
|
|
| 13 |
|
| 14 |
|
| 15 |
def main():
|
| 16 |
-
st.set_page_config(page_title='Today I Learnt',
|
| 17 |
-
|
| 18 |
st.markdown("<div class='container'>", unsafe_allow_html=True)
|
| 19 |
|
| 20 |
st.markdown(
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
def main():
|
| 16 |
+
# st.set_page_config(page_title='Today I Learnt',
|
| 17 |
+
# page_icon='📰', layout='wide')
|
| 18 |
st.markdown("<div class='container'>", unsafe_allow_html=True)
|
| 19 |
|
| 20 |
st.markdown(
|