gradio app
Browse files
app.py
CHANGED
@@ -1,34 +1,6 @@
|
|
1 |
-
import
|
2 |
import requests
|
3 |
|
4 |
-
# Set Streamlit theme to white
|
5 |
-
st.set_page_config(
|
6 |
-
page_title="Job Search",
|
7 |
-
page_icon="π§βπΌ",
|
8 |
-
layout="centered",
|
9 |
-
initial_sidebar_state="expanded"
|
10 |
-
)
|
11 |
-
|
12 |
-
# Apply CSS to enforce a white theme
|
13 |
-
st.markdown("""
|
14 |
-
<style>
|
15 |
-
body {
|
16 |
-
background-color: #ffffff;
|
17 |
-
color: #000000;
|
18 |
-
}
|
19 |
-
.stApp {
|
20 |
-
background-color: #ffffff;
|
21 |
-
}
|
22 |
-
.stTextInput, .stSelectbox, .stButton {
|
23 |
-
background-color: #ffffff;
|
24 |
-
color: #000000;
|
25 |
-
}
|
26 |
-
</style>
|
27 |
-
""", unsafe_allow_html=True)
|
28 |
-
|
29 |
-
st.title("π― Career Connect ")
|
30 |
-
st.write("Find the latest job openings based on your preferences.")
|
31 |
-
|
32 |
# API credentials
|
33 |
API_KEY = "c1b9b6be0amsh11316ef9a922bdbp1789f5jsn18a0023eef11"
|
34 |
API_HOST = "jsearch.p.rapidapi.com"
|
@@ -49,40 +21,49 @@ def get_job_openings(job_title, location, location_type, experience):
|
|
49 |
}
|
50 |
|
51 |
response = requests.get(url, headers=headers, params=querystring)
|
|
|
52 |
if response.status_code == 200:
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
# User inputs
|
59 |
-
job_title = st.text_input("Enter Job Title:", placeholder="e.g., Node.js Developer")
|
60 |
-
location = st.text_input("Enter Location:", placeholder="e.g., New York")
|
61 |
-
location_type = st.selectbox("Location Type:", ["ANY", "ON_SITE", "REMOTE", "HYBRID"])
|
62 |
-
experience = st.selectbox("Experience Level:", ["FULLTIME", "PARTTIME", "INTERN", "CONTRACTOR"])
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
st.write(f"*Type:* {job.get('job_employment_type', 'N/A')}")
|
79 |
-
st.write(f"*Posted On:* {job.get('job_posted_at_datetime_utc', 'N/A')}")
|
80 |
-
st.write(f"*Deadline:* {job.get('job_offer_expiration_datetime_utc', 'N/A')}")
|
81 |
-
st.write(f"[π View Job Posting]({job.get('job_apply_link', '#')})")
|
82 |
-
st.write("---")
|
83 |
-
else:
|
84 |
-
st.warning("No job openings found. Please try different inputs.")
|
85 |
else:
|
86 |
-
|
|
|
|
|
87 |
else:
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
import requests
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# API credentials
|
5 |
API_KEY = "c1b9b6be0amsh11316ef9a922bdbp1789f5jsn18a0023eef11"
|
6 |
API_HOST = "jsearch.p.rapidapi.com"
|
|
|
21 |
}
|
22 |
|
23 |
response = requests.get(url, headers=headers, params=querystring)
|
24 |
+
|
25 |
if response.status_code == 200:
|
26 |
+
data = response.json()
|
27 |
+
if data and 'data' in data:
|
28 |
+
jobs = data['data']
|
29 |
+
job_cards = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
if jobs:
|
32 |
+
for job in jobs:
|
33 |
+
job_cards += f"""
|
34 |
+
<div style="border: 2px solid #ddd; padding: 15px; border-radius: 10px; margin-bottom: 15px; background-color: #f9f9f9;">
|
35 |
+
<h3 style="color: #333;">{job.get('job_title', 'No Title')}</h3>
|
36 |
+
<p style="color: #333;"><strong style="color: #333;">Company:</strong> {job.get('employer_name', 'Unknown')}</p>
|
37 |
+
<p style="color: #333;"><strong style="color: #333;">Location:</strong> {job.get('job_city', 'Unknown')}, {job.get('job_country', '')}</p>
|
38 |
+
<p style="color: #333;"><strong style="color: #333;">Type:</strong> {job.get('job_employment_type', 'N/A')}</p>
|
39 |
+
<p style="color: #333;"><strong style="color: #333;">Posted On:</strong> {job.get('job_posted_at_datetime_utc', 'N/A')}</p>
|
40 |
+
<p style="color: #333;"><strong style="color: #333;">Deadline:</strong> {job.get('job_offer_expiration_datetime_utc', 'N/A')}</p>
|
41 |
+
<a href="{job.get('job_apply_link', '#')}" target="_blank" style="color: #007bff; text-decoration: none;">π Apply Now</a>
|
42 |
+
</div>
|
43 |
+
"""
|
44 |
+
return job_cards
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
else:
|
46 |
+
return "<p style='color: red;'>β οΈ No job openings found. Try different inputs.</p>"
|
47 |
+
else:
|
48 |
+
return "<p style='color: red;'>β οΈ No job data found. Try again.</p>"
|
49 |
else:
|
50 |
+
return f"<p style='color: red;'>β Error {response.status_code}: {response.text}</p>"
|
51 |
+
|
52 |
+
# Gradio UI
|
53 |
+
with gr.Blocks(theme=gr.themes.Base()) as demo:
|
54 |
+
gr.Markdown("# π― Career Connect")
|
55 |
+
gr.Markdown("Find the latest job openings based on your preferences.")
|
56 |
+
|
57 |
+
job_title = gr.Textbox(label="Enter Job Title", placeholder="e.g., Node.js Developer")
|
58 |
+
location = gr.Textbox(label="Enter Location", placeholder="e.g., New York")
|
59 |
+
location_type = gr.Dropdown(["ANY", "ON_SITE", "REMOTE", "HYBRID"], label="Location Type")
|
60 |
+
experience = gr.Dropdown(["FULLTIME", "PARTTIME", "INTERN", "CONTRACTOR"], label="Experience Level")
|
61 |
+
|
62 |
+
submit = gr.Button("π Search Jobs")
|
63 |
+
result = gr.HTML()
|
64 |
+
|
65 |
+
submit.click(get_job_openings, inputs=[job_title, location, location_type, experience], outputs=result)
|
66 |
+
|
67 |
+
# Launch the Gradio app
|
68 |
+
if __name__ == "__main__":
|
69 |
+
demo.launch()
|