ASNVS commited on
Commit
059e7e2
Β·
verified Β·
1 Parent(s): a29607c

small update

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -3,7 +3,7 @@ import requests
3
  import os
4
  import subprocess
5
  import threading
6
- import time
7
 
8
  # API credentials for job search
9
  API_KEY = "c1b9b6be0amsh11316ef9a922bdbp1789f5jsn18a0023eef11"
@@ -39,7 +39,6 @@ def search_jobs(job_title, location, location_type, employment_type, salary_min,
39
  return jobs
40
  if not jobs:
41
  return "No job openings found. Please try different inputs."
42
-
43
  return "\n\n".join(
44
  f"{idx}. {job.get('job_title', 'No Title')}\n"
45
  f"Company: {job.get('employer_name', 'Unknown')}\n"
@@ -55,6 +54,7 @@ def search_jobs(job_title, location, location_type, employment_type, salary_min,
55
  # Function to launch Career Counselor App in a separate thread
56
  def launch_career_counselor():
57
  def run_streamlit():
 
58
  with open("career_counselor.py", "w") as f:
59
  f.write("""
60
  import os
@@ -95,9 +95,15 @@ if st.button("Get Career Advice"):
95
  st.markdown("---")
96
  st.markdown("<p style='text-align: center;'>Designed by Career Expert</p>", unsafe_allow_html=True)
97
  """)
98
-
99
- subprocess.Popen(["streamlit", "run", "career_counselor.py"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
100
-
 
 
 
 
 
 
101
  threading.Thread(target=run_streamlit, daemon=True).start()
102
 
103
  # Function to handle option selection
@@ -112,9 +118,8 @@ def main(option):
112
  with gr.Blocks() as iface:
113
  gr.Markdown("# 🌟 Career Guidance & Job Search")
114
  gr.Markdown("Choose between job searching or AI-powered career guidance.")
115
-
116
  option = gr.Radio(["Career Connect (Job Search)", "Career Counselor App"], label="Select an Option")
117
-
118
  # Job search UI
119
  job_search_interface = gr.Interface(
120
  fn=search_jobs,
@@ -122,17 +127,17 @@ with gr.Blocks() as iface:
122
  gr.Textbox(label="Enter Job Title", placeholder="e.g., Node.js Developer"),
123
  gr.Textbox(label="Enter Location", placeholder="e.g., New York"),
124
  gr.Radio(["ANY", "ON_SITE", "REMOTE", "HYBRID"], label="Location Type"),
125
- gr.CheckboxGroup(["FULLTIME", "PARTTIME", "INTERN", "CONTRACTOR"], label="Select Employment Type",
126
- value=["FULLTIME", "INTERN"]),
127
  gr.Number(label="Minimum Salary ($)", value=0, minimum=0),
128
  gr.Number(label="Maximum Salary ($)", value=100000, minimum=0)
129
  ],
130
  outputs=gr.Textbox(label="Job Openings"),
131
  visible=False
132
  )
133
-
134
  counselor_status = gr.Markdown("", visible=False)
135
-
136
  option.change(main, inputs=option, outputs=[job_search_interface, counselor_status, gr.Textbox(label="Status")])
137
 
138
  iface.launch()
 
3
  import os
4
  import subprocess
5
  import threading
6
+ import sys
7
 
8
  # API credentials for job search
9
  API_KEY = "c1b9b6be0amsh11316ef9a922bdbp1789f5jsn18a0023eef11"
 
39
  return jobs
40
  if not jobs:
41
  return "No job openings found. Please try different inputs."
 
42
  return "\n\n".join(
43
  f"{idx}. {job.get('job_title', 'No Title')}\n"
44
  f"Company: {job.get('employer_name', 'Unknown')}\n"
 
54
  # Function to launch Career Counselor App in a separate thread
55
  def launch_career_counselor():
56
  def run_streamlit():
57
+ # Write the Streamlit app code to career_counselor.py
58
  with open("career_counselor.py", "w") as f:
59
  f.write("""
60
  import os
 
95
  st.markdown("---")
96
  st.markdown("<p style='text-align: center;'>Designed by Career Expert</p>", unsafe_allow_html=True)
97
  """)
98
+ # Create a clean environment and reset sys.argv to avoid extra command-line arguments
99
+ env = os.environ.copy()
100
+ sys.argv = ["streamlit", "run", "career_counselor.py"]
101
+ subprocess.Popen(
102
+ ["streamlit", "run", "career_counselor.py"],
103
+ stdout=subprocess.DEVNULL,
104
+ stderr=subprocess.DEVNULL,
105
+ env=env
106
+ )
107
  threading.Thread(target=run_streamlit, daemon=True).start()
108
 
109
  # Function to handle option selection
 
118
  with gr.Blocks() as iface:
119
  gr.Markdown("# 🌟 Career Guidance & Job Search")
120
  gr.Markdown("Choose between job searching or AI-powered career guidance.")
 
121
  option = gr.Radio(["Career Connect (Job Search)", "Career Counselor App"], label="Select an Option")
122
+
123
  # Job search UI
124
  job_search_interface = gr.Interface(
125
  fn=search_jobs,
 
127
  gr.Textbox(label="Enter Job Title", placeholder="e.g., Node.js Developer"),
128
  gr.Textbox(label="Enter Location", placeholder="e.g., New York"),
129
  gr.Radio(["ANY", "ON_SITE", "REMOTE", "HYBRID"], label="Location Type"),
130
+ gr.CheckboxGroup(["FULLTIME", "PARTTIME", "INTERN", "CONTRACTOR"],
131
+ label="Select Employment Type", value=["FULLTIME", "INTERN"]),
132
  gr.Number(label="Minimum Salary ($)", value=0, minimum=0),
133
  gr.Number(label="Maximum Salary ($)", value=100000, minimum=0)
134
  ],
135
  outputs=gr.Textbox(label="Job Openings"),
136
  visible=False
137
  )
138
+
139
  counselor_status = gr.Markdown("", visible=False)
140
+
141
  option.change(main, inputs=option, outputs=[job_search_interface, counselor_status, gr.Textbox(label="Status")])
142
 
143
  iface.launch()