Jofax commited on
Commit
8ce6986
·
verified ·
1 Parent(s): c23c315

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +109 -0
app.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ from datetime import datetime
4
+
5
+ # --- CUSTOM CSS FOR SOOTHING UI ---
6
+ custom_css = """
7
+ .gradio-container {
8
+ background-color: #f0f7f9 !important;
9
+ font-family: 'Inter', sans-serif !important;
10
+ }
11
+ .main-header {
12
+ text-align: center;
13
+ color: #0077b6;
14
+ margin-bottom: 20px;
15
+ }
16
+ .promo-card {
17
+ background: linear-gradient(135deg, #00b4d8, #0077b6);
18
+ color: white;
19
+ padding: 20px;
20
+ border-radius: 15px;
21
+ box-shadow: 0 4px 15px rgba(0,0,0,0.1);
22
+ margin-bottom: 20px;
23
+ text-align: center;
24
+ }
25
+ .hotel-card {
26
+ border-radius: 12px !important;
27
+ border: 1px solid #e0e0e0 !important;
28
+ background: white !important;
29
+ transition: all 0.3s ease;
30
+ }
31
+ .hotel-card:hover {
32
+ transform: translateY(-2px);
33
+ box-shadow: 0 5px 15px rgba(0,0,0,0.05);
34
+ }
35
+ footer {display: none !important;}
36
+ """
37
+
38
+ # --- DATA ---
39
+ data = {
40
+ "🏨 Hotel Name": ["Coral Reef View", "Male Grand Stay", "Villi Blue Inn"],
41
+ "📍 Location": ["Hulhumale Phase 1", "Male' City", "Villingili"],
42
+ "💰 Price/Night": ["850 MVR", "1,100 MVR", "650 MVR"],
43
+ "✅ Status": ["Available", "Available", "Occupied"],
44
+ "📞 Direct Contact": ["+960 7771234", "+960 7785678", "+960 7799101"]
45
+ }
46
+ df = pd.DataFrame(data)
47
+
48
+ # --- FUNCTIONS ---
49
+ def send_deal(hotel, msg):
50
+ if not msg: return gr.update(visible=False), ""
51
+ time_now = datetime.now().strftime("%H:%M")
52
+ alert_html = f"""
53
+ <div class='promo-card'>
54
+ <p style='font-size: 1.2em; margin: 0;'>🔥 <b>FLASH DEAL</b> from {hotel}</p>
55
+ <p style='font-size: 1.5em; font-weight: bold; margin: 10px 0;'>"{msg}"</p>
56
+ <p style='font-size: 0.8em; opacity: 0.8;'>Posted at {time_now} • Valid for tonight only</p>
57
+ </div>
58
+ """
59
+ return gr.update(value=alert_html, visible=True), "✅ Promotion sent to all users!"
60
+
61
+ # --- UI LAYOUT ---
62
+ with gr.Blocks(css=custom_css, title="Hulhumale Room Finder") as demo:
63
+
64
+ # Header Section
65
+ gr.HTML("<div class='main-header'><h1>🏝️ Hulhumale Direct</h1><p>Real-time rooms in Male', Hulhumale & Villingili</p></div>")
66
+
67
+ # Active Promotion Area (Hidden by default)
68
+ promo_display = gr.HTML(visible=False)
69
+
70
+ with gr.Tabs() as tabs:
71
+
72
+ # --- TRAVELER TAB ---
73
+ with gr.Tab("🔍 Find a Room"):
74
+ with gr.Row():
75
+ filter_loc = gr.Radio(["All", "Male' City", "Hulhumale", "Villingili"], value="All", label="Filter by Island")
76
+
77
+ room_table = gr.DataFrame(
78
+ value=df,
79
+ interactive=False,
80
+ elem_classes="hotel-card"
81
+ )
82
+
83
+ with gr.Row():
84
+ gr.Markdown("ℹ️ **How to book:** Copy the number and call/Viber the owner directly. No commission fees!")
85
+ refresh_btn = gr.Button("🔄 Refresh Availability", size="sm")
86
+
87
+ # --- OWNER TAB ---
88
+ with gr.Tab("⚙️ Hotel Dashboard"):
89
+ gr.Markdown("### 🔑 Client Portal (350 MVR/mo)")
90
+
91
+ with gr.Row():
92
+ with gr.Column(scale=1):
93
+ owner_hotel = gr.Dropdown(choices=list(data["🏨 Hotel Name"]), label="Your Property")
94
+ new_status = gr.Radio(["Available", "Occupied"], label="Current Status")
95
+ update_price = gr.Textbox(label="Tonight's Price (MVR)", placeholder="e.g. 750")
96
+ update_btn = gr.Button("💾 Update Live Listing", variant="secondary")
97
+
98
+ with gr.Column(scale=1):
99
+ gr.Markdown("### 📣 Marketing Tools")
100
+ promo_text = gr.Textbox(placeholder="e.g. 15% off for airport arrivals!", label="Flash Promotion Message")
101
+ promo_btn = gr.Button("🚀 Blast Notification", variant="primary")
102
+ status_msg = gr.Markdown("")
103
+
104
+ # --- LOGIC ---
105
+ promo_btn.click(send_deal, inputs=[owner_hotel, promo_text], outputs=[promo_display, status_msg])
106
+
107
+ gr.HTML("<div style='text-align:center; margin-top:50px; opacity:0.5;'><p>Reliable Local App Concept © 2024</p></div>")
108
+
109
+ demo.launch()