Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -87,11 +87,57 @@ def haversine(lat1, lon1, lat2, lon2):
|
|
87 |
distance = R * c
|
88 |
return distance
|
89 |
|
90 |
-
# Function to handle form submission
|
91 |
-
@st.experimental_dialog("Fill out the form")
|
92 |
-
def form_dialog():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
city = st.selectbox("City", ['San Francisco', 'Oakland', 'Berkeley'])
|
94 |
-
zipcode = st.
|
95 |
|
96 |
sex = st.radio("Sex", ["Male", "Female", "Other"])
|
97 |
lgbtq = st.radio("Do you identify as LGBTQ+ (some shelters serve this community specifically)", ["No", "Yes"])
|
@@ -119,25 +165,6 @@ def form_dialog():
|
|
119 |
st.session_state.form_submitted = True
|
120 |
st.session_state.data = data
|
121 |
st.rerun()
|
122 |
-
|
123 |
-
# Initialize session state
|
124 |
-
if 'form_submitted' not in st.session_state:
|
125 |
-
st.session_state.form_submitted = False
|
126 |
-
|
127 |
-
if 'shelter_index' not in st.session_state:
|
128 |
-
st.session_state.shelter_index = 0
|
129 |
-
|
130 |
-
# Page config
|
131 |
-
st.set_page_config(
|
132 |
-
page_title="ShelterSearch",
|
133 |
-
layout="wide",
|
134 |
-
)
|
135 |
-
|
136 |
-
st.title("ShelterSearch")
|
137 |
-
|
138 |
-
if not st.session_state.form_submitted:
|
139 |
-
if st.button("Open Form"):
|
140 |
-
form_dialog()
|
141 |
else:
|
142 |
with open('data.json', 'r') as f:
|
143 |
data = json.load(f)
|
|
|
87 |
distance = R * c
|
88 |
return distance
|
89 |
|
90 |
+
# # Function to handle form submission
|
91 |
+
# @st.experimental_dialog("Fill out the form")
|
92 |
+
# def form_dialog():
|
93 |
+
# city = st.selectbox("City", ['San Francisco', 'Oakland', 'Berkeley'])
|
94 |
+
# zipcode = st.selectbox("Zipcode")
|
95 |
+
|
96 |
+
# sex = st.radio("Sex", ["Male", "Female", "Other"])
|
97 |
+
# lgbtq = st.radio("Do you identify as LGBTQ+ (some shelters serve this community specifically)", ["No", "Yes"])
|
98 |
+
# domestic_violence = st.radio("Have you experienced domestic violence (some shelters serve these individuals specifically", ["No", "Yes"])
|
99 |
+
|
100 |
+
# urgency = st.radio("How quickly do you need help?", ("Today", "In the next few days", "In a week or more"))
|
101 |
+
# duration = st.radio("How long do you need a place to stay?", ("Overnight", "A month or less", "A couple of months", "A year or more"))
|
102 |
+
# needs = st.text_area("Optional - Needs (tell us what you need and how we can help)")
|
103 |
+
|
104 |
+
# if st.button("Submit"):
|
105 |
+
# data = {
|
106 |
+
# "City": city,
|
107 |
+
# "Zip Code": zipcode,
|
108 |
+
# "Sex": sex,
|
109 |
+
# "LGBTQ": lgbtq,
|
110 |
+
# "Domestic Violence": domestic_violence,
|
111 |
+
# "Urgency": urgency,
|
112 |
+
# "Duration": duration,
|
113 |
+
# "Needs": needs
|
114 |
+
# }
|
115 |
+
|
116 |
+
# with open('data.json', 'w') as f:
|
117 |
+
# json.dump(data, f)
|
118 |
+
|
119 |
+
# st.session_state.form_submitted = True
|
120 |
+
# st.session_state.data = data
|
121 |
+
# st.rerun()
|
122 |
+
|
123 |
+
# Initialize session state
|
124 |
+
if 'form_submitted' not in st.session_state:
|
125 |
+
st.session_state.form_submitted = False
|
126 |
+
|
127 |
+
if 'shelter_index' not in st.session_state:
|
128 |
+
st.session_state.shelter_index = 0
|
129 |
+
|
130 |
+
# Page config
|
131 |
+
st.set_page_config(
|
132 |
+
page_title="ShelterSearch",
|
133 |
+
layout="wide",
|
134 |
+
)
|
135 |
+
|
136 |
+
st.title("ShelterSearch")
|
137 |
+
|
138 |
+
if not st.session_state.form_submitted:
|
139 |
city = st.selectbox("City", ['San Francisco', 'Oakland', 'Berkeley'])
|
140 |
+
zipcode = st.selectbox("Zipcode")
|
141 |
|
142 |
sex = st.radio("Sex", ["Male", "Female", "Other"])
|
143 |
lgbtq = st.radio("Do you identify as LGBTQ+ (some shelters serve this community specifically)", ["No", "Yes"])
|
|
|
165 |
st.session_state.form_submitted = True
|
166 |
st.session_state.data = data
|
167 |
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
else:
|
169 |
with open('data.json', 'r') as f:
|
170 |
data = json.load(f)
|