Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,38 +1,42 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Check if all inputs are selected
|
11 |
if selected_city == "" or job_keyword.strip() == "" or selected_platform == "":
|
12 |
st.warning("Please select a city, enter a job keyword, and choose a platform.")
|
13 |
else:
|
14 |
-
if st.button(button_state):
|
15 |
-
if button_state == "Search Jobs":
|
16 |
# Construct the URL
|
17 |
base_url = platforms[selected_platform]
|
18 |
search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
|
19 |
|
20 |
# Change button state
|
21 |
-
button_state = "See Jobs"
|
22 |
|
23 |
-
#
|
24 |
-
st.
|
25 |
|
26 |
-
elif button_state == "See Jobs":
|
27 |
# Open the link in a new tab
|
28 |
base_url = platforms[selected_platform]
|
29 |
search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
|
30 |
st.markdown(f'<a href="{search_url}" target="_blank">Open Jobs in New Tab</a>', unsafe_allow_html=True)
|
31 |
|
32 |
-
# Reset button state for new searches
|
33 |
-
button_state = "Search Jobs"
|
34 |
-
st.session_state['button_state'] = button_state
|
35 |
-
|
36 |
-
# Ensure button_state is initialized in st.session_state
|
37 |
-
if 'button_state' not in st.session_state:
|
38 |
-
st.session_state['button_state'] = "Search Jobs"
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
# Initialize platform URLs (you can adjust these as needed)
|
4 |
+
platforms = {
|
5 |
+
"LinkedIn": "https://www.linkedin.com/jobs/search/?keywords={job}&location={city}",
|
6 |
+
"Indeed": "https://www.indeed.com/jobs?q={job}&l={city}",
|
7 |
+
"Glassdoor": "https://www.glassdoor.com/Job/jobs.htm?sc.keyword={job}&locT=&locId=&jobType=&fromAge=any&radius=100&city={city}"
|
8 |
+
}
|
9 |
+
|
10 |
+
# Initialize inputs
|
11 |
+
selected_city = st.text_input("Enter City")
|
12 |
+
job_keyword = st.text_input("Enter Job Keyword")
|
13 |
+
selected_platform = st.selectbox("Select Job Platform", options=["", "LinkedIn", "Indeed", "Glassdoor"])
|
14 |
+
|
15 |
+
# Initialize button state in session
|
16 |
+
if 'button_state' not in st.session_state:
|
17 |
+
st.session_state['button_state'] = "Search Jobs"
|
18 |
|
19 |
# Check if all inputs are selected
|
20 |
if selected_city == "" or job_keyword.strip() == "" or selected_platform == "":
|
21 |
st.warning("Please select a city, enter a job keyword, and choose a platform.")
|
22 |
else:
|
23 |
+
if st.button(st.session_state['button_state']):
|
24 |
+
if st.session_state['button_state'] == "Search Jobs":
|
25 |
# Construct the URL
|
26 |
base_url = platforms[selected_platform]
|
27 |
search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
|
28 |
|
29 |
# Change button state
|
30 |
+
st.session_state['button_state'] = "See Jobs"
|
31 |
|
32 |
+
# Show search URL for debugging purposes (optional)
|
33 |
+
st.write(f"Search URL: {search_url}")
|
34 |
|
35 |
+
elif st.session_state['button_state'] == "See Jobs":
|
36 |
# Open the link in a new tab
|
37 |
base_url = platforms[selected_platform]
|
38 |
search_url = base_url.format(job=job_keyword.replace(" ", "+"), city=selected_city)
|
39 |
st.markdown(f'<a href="{search_url}" target="_blank">Open Jobs in New Tab</a>', unsafe_allow_html=True)
|
40 |
|
41 |
+
# Reset button state for new searches
|
42 |
+
st.session_state['button_state'] = "Search Jobs"
|
|
|
|
|
|
|
|
|
|