Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| def search_jobs_ui(query, location): | |
| """ | |
| Searches job listings using the Indeed API and formats the results. | |
| Args: | |
| query (str): Job title or keyword to search for. | |
| location (str): Location for the job search. | |
| Returns: | |
| str: Markdown-formatted string of job results or error message. | |
| """ | |
| url = f"https://api.indeed.com/jobs?q={query}&l={location}&limit=5" | |
| headers = {"Accept": "application/json"} | |
| try: | |
| response = requests.get(url, headers=headers) | |
| response.raise_for_status() | |
| result = response.json() | |
| except requests.exceptions.RequestException as e: | |
| return f"โ Error: {e}" | |
| jobs = result.get("results", []) | |
| if not jobs: | |
| return "No jobs found for your search." | |
| output = "" | |
| for job in jobs: | |
| title = job.get("title", "No Title") | |
| company = job.get("company", "Unknown Company") | |
| job_location = job.get("location", "Unknown Location") | |
| job_url = job.get("url", "#") | |
| output += f"**{title}** at *{company}*\n๐ {job_location}\n[Apply Here]({job_url})\n\n" | |
| return output | |
| app = gr.Interface( | |
| fn=search_jobs_ui, | |
| inputs=[ | |
| gr.Textbox(label="Job Title / Keyword"), | |
| gr.Textbox(label="Location") | |
| ], | |
| outputs="markdown", | |
| title="Indeed Job Search (Gradio MCP Server)", | |
| description="Search job listings using a smart AI agent powered by Gradio MCP." | |
| ) | |
| if __name__ == "__main__": | |
| app.launch(share=True, mcp_server=True) | |