| import gradio as gr |
| import pandas as pd |
| from datetime import datetime |
|
|
| |
| rooms_data = { |
| "Hotel Name": ["Beach Breeze Hulhumale", "Male City Inn", "Villi Garden"], |
| "Location": ["Hulhumale Phase 1", "Male City", "Villingili"], |
| "Price (MVR)": [850, 1200, 700], |
| "Status": ["Available", "Available", "Full"], |
| "Contact": ["+960 7771234", "+960 7785678", "+960 7799101"] |
| } |
|
|
| df = pd.DataFrame(rooms_data) |
|
|
| def update_status(hotel_index, new_status): |
| df.at[hotel_index, "Status"] = new_status |
| df.at[hotel_index, "Last Update"] = datetime.now().strftime("%H:%M:%S") |
| return df |
|
|
| def get_available_rooms(): |
| return df[df["Status"] == "Available"] |
|
|
| |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: |
| gr.Markdown("# ποΈ Hulhumale Real-Time Room Finder") |
| gr.Markdown("Direct contact for rooms in Male', Hulhumale, and Villingili.") |
| |
| with gr.Tab("Traveler View (User Side)"): |
| gr.Markdown("### π Live Availability") |
| output_table = gr.DataFrame(value=get_available_rooms(), interactive=False) |
| refresh_btn = gr.Button("π Refresh Live Availability") |
| |
| gr.Markdown("> **Tip:** Tap the number to call/Viber the owner directly.") |
|
|
| with gr.Tab("Hotel Owner (Client Side)"): |
| gr.Markdown("### π Owner Dashboard (350 MVR/mo)") |
| hotel_id = gr.Dropdown(choices=list(df["Hotel Name"]), label="Select Your Hotel", type="index") |
| status_radio = gr.Radio(["Available", "Full"], label="Change Room Status") |
| update_btn = gr.Button("Update Availability Now", variant="primary") |
| |
| promo_input = gr.Textbox(label="Add Promotion (e.g., 10% Off Tonight!)") |
| promo_btn = gr.Button("Send Notification to Users") |
|
|
| |
| update_btn.click(update_status, inputs=[hotel_id, status_radio], outputs=output_table) |
| refresh_btn.click(lambda: df[df["Status"] == "Available"], outputs=output_table) |
|
|
| demo.launch() |