Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,20 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
|
4 |
-
#
|
5 |
-
df
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
# Function to vote on a story
|
15 |
def vote_story(index):
|
16 |
-
df.loc[index, 'votes'] += 1
|
17 |
|
18 |
# Function to break story into sentences
|
19 |
def break_into_sentences(story):
|
@@ -24,18 +25,20 @@ def display_story(index, row):
|
|
24 |
sentences = break_into_sentences(row['story'])
|
25 |
for sentence in sentences:
|
26 |
st.text(sentence)
|
27 |
-
st.button(f"Vote for Story {index + 1}"
|
|
|
28 |
|
29 |
# Main app
|
30 |
st.title('Medical Story Voting 🗳️')
|
31 |
|
32 |
# Display stories and voting buttons
|
33 |
-
for index, row in df.iterrows():
|
34 |
col1, col2 = st.columns([3,1])
|
35 |
with col1:
|
36 |
display_story(index, row)
|
37 |
-
col2
|
|
|
38 |
|
39 |
# Display total votes
|
40 |
st.markdown("### 📊 Vote Summary")
|
41 |
-
st.table(df)
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
|
4 |
+
# Initialize session state for the vote counts
|
5 |
+
if 'df' not in st.session_state:
|
6 |
+
st.session_state.df = pd.DataFrame({
|
7 |
+
'story': [
|
8 |
+
"A 45-year-old man presents with a long history of ulcers on the bottom of his feet. 👣🚑",
|
9 |
+
"A 24-year-old man, an information technology professional, gets himself tested for serum immunoglobulin M (IgM) levels. 💻🧪",
|
10 |
+
"A 33-year-old woman who was recently involved in a motor vehicle accident presents to a medical clinic for a follow-up visit. 🚗🏥",
|
11 |
+
],
|
12 |
+
'votes': [0, 0, 0]
|
13 |
+
})
|
14 |
|
15 |
# Function to vote on a story
|
16 |
def vote_story(index):
|
17 |
+
st.session_state.df.loc[index, 'votes'] += 1
|
18 |
|
19 |
# Function to break story into sentences
|
20 |
def break_into_sentences(story):
|
|
|
25 |
sentences = break_into_sentences(row['story'])
|
26 |
for sentence in sentences:
|
27 |
st.text(sentence)
|
28 |
+
if st.button(f"Vote for Story {index + 1}"):
|
29 |
+
vote_story(index)
|
30 |
|
31 |
# Main app
|
32 |
st.title('Medical Story Voting 🗳️')
|
33 |
|
34 |
# Display stories and voting buttons
|
35 |
+
for index, row in st.session_state.df.iterrows():
|
36 |
col1, col2 = st.columns([3,1])
|
37 |
with col1:
|
38 |
display_story(index, row)
|
39 |
+
with col2:
|
40 |
+
st.write(f"Votes: {row['votes']}")
|
41 |
|
42 |
# Display total votes
|
43 |
st.markdown("### 📊 Vote Summary")
|
44 |
+
st.table(st.session_state.df)
|