Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,121 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import requests
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
total_number_pages = 3
|
| 6 |
-
placeholder_buttons = None
|
| 7 |
-
|
| 8 |
-
Q1_radio_options = ["Pineapple","Cheese","Pepperoni","Mushroom","Sausage","Other"]
|
| 9 |
-
Q2_radio_options = ["Football","Baseball","Basketball","Soccer","Golf","Other"]
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
# Function that records radio element changes
|
| 13 |
-
def radio_change(element, state, key):
|
| 14 |
-
st.session_state[state] = element.index(st.session_state[key]) # Setting previously selected option
|
| 15 |
-
# Function that disables the last button while data is uploaded to IPFS
|
| 16 |
-
def button_disable():
|
| 17 |
-
st.session_state['disabled'] = True
|
| 18 |
-
|
| 19 |
-
st.set_page_config(page_title='IPFS-Based Survey',)
|
| 20 |
-
st.title('Test Survey')
|
| 21 |
-
|
| 22 |
-
st.markdown("<style>.row-widget.stButton {text-align: center;}</style>", unsafe_allow_html=True)
|
| 23 |
-
st.markdown("<style>.big-font {font-size:24px;}</style>", unsafe_allow_html=True)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
if "current_page" not in st.session_state:
|
| 27 |
-
st.session_state["current_page"] = 1
|
| 28 |
-
st.session_state["Q1"] = None
|
| 29 |
-
st.session_state["Q2"] = None
|
| 30 |
-
st.session_state["disabled"] = False
|
| 31 |
-
|
| 32 |
-
# Page 1; Video
|
| 33 |
-
if st.session_state["current_page"] == 1:
|
| 34 |
-
|
| 35 |
-
st.markdown("""<p class="big-font">I hope this works :|</p>""", unsafe_allow_html=True)
|
| 36 |
-
st.video("https://www.youtube.com/watch?v=aJb6Dov0jlM")
|
| 37 |
-
|
| 38 |
-
placeholder = st.empty()
|
| 39 |
-
|
| 40 |
-
if st.button('Next', key='next_button_page_1'):
|
| 41 |
-
all_answered = True
|
| 42 |
-
if all_answered:
|
| 43 |
-
st.session_state["current_page"] += 1
|
| 44 |
-
st.rerun()
|
| 45 |
-
else:
|
| 46 |
-
with placeholder.container():
|
| 47 |
-
st.warning("Please answer all the questions on this page.", icon="⚠️")
|
| 48 |
-
|
| 49 |
-
st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
elif st.session_state["current_page"] == 2:
|
| 53 |
-
|
| 54 |
-
st.radio(label = "What is your favorite type of pizza?",
|
| 55 |
-
options = Q1_radio_options,
|
| 56 |
-
index = None if st.session_state["Q1"] == None else st.session_state["Q1"],
|
| 57 |
-
key = 'Q1_radio',
|
| 58 |
-
on_change = radio_change,
|
| 59 |
-
args = (Q1_radio_options, "Q1", "Q1_radio",))
|
| 60 |
-
|
| 61 |
-
# The code below changes the font size of the above radio's label.
|
| 62 |
-
st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
placeholder = st.empty()
|
| 66 |
-
|
| 67 |
-
col1, col2 = st.columns(2)
|
| 68 |
-
with col1:
|
| 69 |
-
if st.button('Back'):
|
| 70 |
-
st.session_state["current_page"] -= 1
|
| 71 |
-
st.rerun()
|
| 72 |
-
with col2:
|
| 73 |
-
if st.button('Next', key='next_button_page_2'):
|
| 74 |
-
all_answered = True
|
| 75 |
-
if st.session_state["Q1"] == None:
|
| 76 |
-
all_answered = False
|
| 77 |
-
if all_answered:
|
| 78 |
-
st.session_state["current_page"] += 1
|
| 79 |
-
st.rerun()
|
| 80 |
-
else:
|
| 81 |
-
with placeholder.container():
|
| 82 |
-
st.warning("Please answer all the questions on this page.", icon="⚠️")
|
| 83 |
-
|
| 84 |
-
st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
elif st.session_state["current_page"] == 3:
|
| 88 |
-
|
| 89 |
-
st.radio(label = "Favorite Sport?",
|
| 90 |
-
options = Q2_radio_options,
|
| 91 |
-
index = None if st.session_state["Q2"] == None else st.session_state["Q2"],
|
| 92 |
-
key = 'Q2_radio',
|
| 93 |
-
on_change = radio_change,
|
| 94 |
-
args = (Q2_radio_options, "Q2", "Q2_radio",))
|
| 95 |
-
|
| 96 |
-
# The code below changes the font size of the above radio's label.
|
| 97 |
-
st.markdown("""<style> div[class*="stRadio"] > label > div[data-testid="stMarkdownContainer"] > p {font-size: 24px;}</style> <br><br>""", unsafe_allow_html=True)
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
placeholder = st.empty()
|
| 101 |
-
|
| 102 |
-
col1, col2 = st.columns(2)
|
| 103 |
-
with col1:
|
| 104 |
-
if st.button('Back'):
|
| 105 |
-
st.session_state["current_page"] -= 1
|
| 106 |
-
st.rerun()
|
| 107 |
-
with col2:
|
| 108 |
-
if st.button('Next', key='next_button_page_undefined'):
|
| 109 |
-
all_answered = True
|
| 110 |
-
if st.session_state["Q2"] == None:
|
| 111 |
-
all_answered = False
|
| 112 |
-
if all_answered:
|
| 113 |
-
st.session_state["current_page"] += 1
|
| 114 |
-
st.rerun()
|
| 115 |
-
else:
|
| 116 |
-
with placeholder.container():
|
| 117 |
-
st.warning("Please answer all the questions on this page.", icon="⚠️")
|
| 118 |
-
|
| 119 |
-
st.progress(st.session_state["current_page"]/total_number_pages, text="Progress")
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|