OppaAI commited on
Commit
0a4b4e5
·
verified ·
1 Parent(s): f21c27f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ def search_jobs_ui(query, location):
5
+ """
6
+ Searches job listings using the Indeed API and formats the results.
7
+
8
+ Args:
9
+ query (str): Job title or keyword to search for.
10
+ location (str): Location for the job search.
11
+
12
+ Returns:
13
+ str: Markdown-formatted string of job results or error message.
14
+ """
15
+ url = f"https://api.indeed.com/jobs?q={query}&l={location}&limit=5"
16
+ headers = {"Accept": "application/json"}
17
+
18
+ try:
19
+ response = requests.get(url, headers=headers)
20
+ response.raise_for_status()
21
+ result = response.json()
22
+ except requests.exceptions.RequestException as e:
23
+ return f"❌ Error: {e}"
24
+
25
+ jobs = result.get("results", [])
26
+ if not jobs:
27
+ return "No jobs found for your search."
28
+
29
+ output = ""
30
+ for job in jobs:
31
+ title = job.get("title", "No Title")
32
+ company = job.get("company", "Unknown Company")
33
+ job_location = job.get("location", "Unknown Location")
34
+ job_url = job.get("url", "#")
35
+
36
+ output += f"**{title}** at *{company}*\n📍 {job_location}\n[Apply Here]({job_url})\n\n"
37
+
38
+ return output
39
+
40
+ app = gr.Interface(
41
+ fn=search_jobs_ui,
42
+ inputs=[
43
+ gr.Textbox(label="Job Title / Keyword"),
44
+ gr.Textbox(label="Location")
45
+ ],
46
+ outputs="markdown",
47
+ title="Indeed Job Search (Gradio MCP Server)",
48
+ description="Search job listings using a smart AI agent powered by Gradio MCP."
49
+ )
50
+
51
+ if __name__ == "__main__":
52
+ app.launch(share=True, mcp_server=True)