Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,24 +18,39 @@ platforms = {
|
|
18 |
# App Title
|
19 |
st.title("Job Search Portal")
|
20 |
|
21 |
-
# User Inputs
|
22 |
st.subheader("Search for Jobs in Pakistan")
|
23 |
-
selected_city = st.selectbox("Select your city:", cities)
|
24 |
job_keyword = st.text_input("Enter job title or keywords:")
|
25 |
-
selected_platform = st.selectbox("Choose the job platform:", list(platforms.keys()))
|
26 |
-
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# App Title
|
19 |
st.title("Job Search Portal")
|
20 |
|
21 |
+
# User Inputs (with empty initial selection)
|
22 |
st.subheader("Search for Jobs in Pakistan")
|
23 |
+
selected_city = st.selectbox("Select your city:", [""] + cities) # Add empty string
|
24 |
job_keyword = st.text_input("Enter job title or keywords:")
|
25 |
+
selected_platform = st.selectbox("Choose the job platform:", [""] + list(platforms.keys())) # Add empty string
|
26 |
+
|
27 |
+
# Initialize button state
|
28 |
+
button_state = "Search Jobs"
|
29 |
+
|
30 |
+
# Check if all inputs are selected
|
31 |
+
if selected_city == "" or job_keyword.strip() == "" or selected_platform == "":
|
32 |
+
st.warning("Please select a city, enter a job keyword, and choose a platform.")
|
33 |
+
else:
|
34 |
+
if st.button(button_state):
|
35 |
+
if button_state == "Search Jobs":
|
36 |
+
# Construct the URL
|
37 |
+
base_url = platforms[selected_platform]
|
38 |
+
search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
|
39 |
+
|
40 |
+
# Change button state
|
41 |
+
button_state = "See Jobs"
|
42 |
+
st.experimental_rerun() # Force a rerun to update the button
|
43 |
+
|
44 |
+
elif button_state == "See Jobs":
|
45 |
+
# Open the link in a new tab
|
46 |
+
base_url = platforms[selected_platform]
|
47 |
+
search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
|
48 |
+
st.markdown(f'<a href="{search_url}" target="_blank">Open Jobs in New Tab</a>', unsafe_allow_html=True)
|
49 |
+
|
50 |
+
# Reset button state for new searches.
|
51 |
+
button_state = "Search Jobs"
|
52 |
+
st.experimental_rerun()
|
53 |
+
|
54 |
+
# This is a very important line that prevents the session from being saved after the button is clicked.
|
55 |
+
if 'button_state' not in st.session_state:
|
56 |
+
st.session_state['button_state'] = "Search Jobs"
|