Spaces:
Sleeping
Sleeping
eaglelandsonce
commited on
Create 30_Medical_Architectures.py
Browse files
pages/30_Medical_Architectures.py
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import json
|
3 |
+
|
4 |
+
# Set page configuration to wide screen
|
5 |
+
st.set_page_config(layout="wide")
|
6 |
+
|
7 |
+
# Load the data from the external JSON file
|
8 |
+
with open('data.json', 'r') as file:
|
9 |
+
data = json.load(file)
|
10 |
+
|
11 |
+
# Set up session state to keep track of the current index
|
12 |
+
if 'current_index' not in st.session_state:
|
13 |
+
st.session_state.current_index = 0
|
14 |
+
|
15 |
+
# Function to display the current article
|
16 |
+
def display_article(index):
|
17 |
+
article = data['articles'][index]
|
18 |
+
|
19 |
+
# Display the title and description
|
20 |
+
st.markdown(f"<h2 style='text-align: center;'>{article['title']}</h2>", unsafe_allow_html=True)
|
21 |
+
st.write(article['description'])
|
22 |
+
|
23 |
+
# Display the image centered
|
24 |
+
st.image(article['image'], use_column_width=True, caption=article['title'])
|
25 |
+
|
26 |
+
# Display the link
|
27 |
+
st.markdown(f"<div style='text-align: center;'><a href='{article['href']}' target='_blank'>Read more</a></div>", unsafe_allow_html=True)
|
28 |
+
|
29 |
+
# Function to handle navigation via buttons
|
30 |
+
def next_article():
|
31 |
+
if st.session_state.current_index < len(data['articles']) - 1:
|
32 |
+
st.session_state.current_index += 1
|
33 |
+
|
34 |
+
def previous_article():
|
35 |
+
if st.session_state.current_index > 0:
|
36 |
+
st.session_state.current_index -= 1
|
37 |
+
|
38 |
+
# Dropdown to select an article by title
|
39 |
+
options = [article['title'] for article in data['articles']]
|
40 |
+
selected_title = st.selectbox("Select an Architecture", options, index=st.session_state.current_index)
|
41 |
+
|
42 |
+
# Add the Medical Architect Assistant link directly below the dropdown
|
43 |
+
st.markdown(
|
44 |
+
"""
|
45 |
+
<div style='text-align: center;'>
|
46 |
+
<a href='https://chatgpt.com/g/g-UexWaSEjO-medical-cloud-architect' target='_blank' style='font-size: 20px; color: #2C6BA0;'>
|
47 |
+
Medical Cloud Architect Assistant
|
48 |
+
</a>
|
49 |
+
</div>
|
50 |
+
""",
|
51 |
+
unsafe_allow_html=True
|
52 |
+
)
|
53 |
+
|
54 |
+
# Find the selected article index based on the title
|
55 |
+
for i, article in enumerate(data['articles']):
|
56 |
+
if article['title'] == selected_title:
|
57 |
+
st.session_state.current_index = i
|
58 |
+
break
|
59 |
+
|
60 |
+
# Display the current article
|
61 |
+
display_article(st.session_state.current_index)
|
62 |
+
|
63 |
+
# Add navigation buttons
|
64 |
+
col1, col2, col3 = st.columns([1, 1, 1])
|
65 |
+
with col1:
|
66 |
+
st.button("Previous", on_click=previous_article)
|
67 |
+
with col3:
|
68 |
+
st.button("Next", on_click=next_article)
|
69 |
+
|
70 |
+
# Show the current index out of total articles
|
71 |
+
st.write(f"Article {st.session_state.current_index + 1} of {len(data['articles'])}")
|
72 |
+
|
73 |
+
# Make the app fullscreen-friendly and wide screen
|
74 |
+
st.markdown(
|
75 |
+
"""
|
76 |
+
<style>
|
77 |
+
.main {
|
78 |
+
max-width: 100%;
|
79 |
+
padding-left: 10px;
|
80 |
+
padding-right: 10px;
|
81 |
+
}
|
82 |
+
img {
|
83 |
+
display: block;
|
84 |
+
margin-left: auto;
|
85 |
+
margin-right: auto;
|
86 |
+
max-width: 80%;
|
87 |
+
}
|
88 |
+
h2 {
|
89 |
+
text-align: center;
|
90 |
+
}
|
91 |
+
</style>
|
92 |
+
""",
|
93 |
+
unsafe_allow_html=True
|
94 |
+
)
|