Download app.py from zsadat/FOS: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/zsadat/FOS/resolve/main/app.py
- Command line
-
hf download hf://spaces/zsadat/FOS/app.py
-
curl -L -o app.py https://huggingface.co/spaces/zsadat/FOS/resolve/main/app.py
1.06 kB
| import gradio as gr | |
| from gmail_handler import get_latest_email | |
| from whatsapp_handler import send_whatsapp | |
| import json | |
| # Load config | |
| with open("config.json") as f: | |
| config = json.load(f) | |
| # Main processing function | |
| def process_email(): | |
| email = get_latest_email() | |
| if "appointment" in email.lower(): | |
| # Very simple hospital name lookup | |
| if "City Hospital" in email: | |
| hospital_no = config["City Hospital"] | |
| elif "General Clinic" in email: | |
| hospital_no = config["General Clinic"] | |
| else: | |
| return "Hospital not recognized." | |
| message = ( | |
| f"New Appointment Request:\n\n" | |
| f"{email}\n\n" | |
| "Reply with:\n1. Booked ✅\n2. Not Available ❌ and suggest date." | |
| ) | |
| send_whatsapp(hospital_no, message) | |
| return f"Message sent to hospital WhatsApp: {hospital_no}" | |
| return "No appointment email detected." | |
| gr.Interface(fn=process_email, inputs=[], outputs="text", title="📩 Appointment Agent").launch() | |