Jofax commited on
Commit
333bb85
Β·
verified Β·
1 Parent(s): a12d01d

Update App.py

Browse files
Files changed (1) hide show
  1. App.py +37 -68
App.py CHANGED
@@ -1,79 +1,48 @@
1
  import gradio as gr
2
  import pandas as pd
3
- import folium
4
- from datetime import datetime
5
 
6
- # --- DATABASE ENGINE (Derived from your research files) ---
7
- # This dictionary simulates the real-time data fetched from the FollowMe API
8
- def get_fleet_data():
9
- return pd.DataFrame([
10
- {"id": "18175", "name": "Island 1", "type": "Speed Boat", "atoll": "Male", "contact": "7772658", "lat": 4.175, "lon": 73.509, "speed": 34},
11
- {"id": "18365", "name": "Ice-9", "type": "Supply Boat", "atoll": "N. Lhohi", "contact": "7781552", "lat": 4.185, "lon": 73.515, "speed": 12},
12
- {"id": "13158", "name": "Kudhibe", "type": "Speed Boat", "atoll": "AA. Rasdhoo", "contact": "7773539", "lat": 4.210, "lon": 73.535, "speed": 29},
13
- {"id": "18621", "name": "Kinaaraa", "type": "Speed Boat", "atoll": "V. Fulidhoo", "contact": "7776406", "lat": 4.191, "lon": 73.520, "speed": 31},
14
- {"id": "18123", "name": "Nazuma 2", "type": "Supply Boat", "atoll": "Th. Hirilandhoo", "contact": "7784013", "lat": 4.160, "lon": 73.500, "speed": 10},
15
- {"id": "17540", "name": "Gems 5", "type": "Supply Boat", "atoll": "K. Thilafushi", "contact": "7785507", "lat": 4.170, "lon": 73.490, "speed": 8}
16
- ])
17
 
18
- # --- UI LOGIC: REAL-TIME RADAR ---
19
- def update_map(search=""):
20
- df = get_fleet_data()
21
- if search:
22
- df = df[df['name'].str.contains(search, case=False) | df['atoll'].str.contains(search, case=False)]
 
 
 
 
 
 
23
 
24
- # Create the OdiGo "Dark Mode" Radar
25
- m = folium.Map(location=[4.175, 73.509], zoom_start=12, tiles="CartoDB dark_matter")
26
 
27
- for _, boat in df.iterrows():
28
- # Live Speed Indicators
29
- color = "#00f2ff" if boat['speed'] > 25 else "#ffa500" # Cyan for fast, Orange for supply
30
- folium.CircleMarker(
31
- location=[boat['lat'], boat['lon']],
32
- radius=8, color=color, fill=True, fill_opacity=0.9,
33
- popup=f"<b>{boat['name']}</b><br>Speed: {boat['speed']} knots<br>Atoll: {boat['atoll']}"
34
- ).add_to(m)
35
-
36
- return m._repr_html_(), df[['name', 'type', 'speed', 'atoll']]
37
 
38
- # --- GEN Z "LIQUID" STYLING ---
39
- css = """
40
- .gradio-container { background: #0a0a0c !important; color: #e0e0e0 !important; font-family: 'Inter', sans-serif; }
41
- #title { font-size: 45px; font-weight: 900; background: linear-gradient(90deg, #00f2ff, #0072ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 0px; }
42
- .glass-box { background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 20px; padding: 20px; }
 
 
 
 
 
43
  """
44
 
45
- # --- APP LAYOUT ---
46
- with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
47
- gr.HTML("<h1 id='title'>ODIGO</h1><p style='color:#666;'>MALDIVES MARITIME ENGINE</p>")
48
-
49
- with gr.Row(elem_classes="glass-box"):
50
- with gr.Column(scale=3):
51
- search_bar = gr.Textbox(placeholder="πŸ” Search Vessel or Atoll (e.g., Male, Ice-9)...", show_label=False)
52
- map_display = gr.HTML()
53
-
54
- with gr.Column(scale=1):
55
- gr.Markdown("### πŸ’Ž Sea-Pass Plus (50 MVR)")
56
- vessel_select = gr.Dropdown(choices=get_fleet_data()['name'].tolist(), label="Active Vessel ID")
57
- status_out = gr.Markdown("**Status:** Radar Scanning...")
58
-
59
- with gr.Row():
60
- viber_btn = gr.Button("Viber (Cargo)", variant="secondary")
61
- wa_btn = gr.Button("WhatsApp (Speed)", variant="primary")
62
-
63
- gr.Markdown("---")
64
- gr.Markdown("### βš“ Vessel Quick-Stats")
65
- data_table = gr.Dataframe(interactive=False)
66
-
67
- # REACTION ENGINE
68
- search_bar.change(update_map, inputs=search_bar, outputs=[map_display, data_table])
69
- demo.load(update_map, outputs=[map_display, data_table])
70
-
71
- # Direct Action Logic
72
- def get_status(name):
73
- v = get_fleet_data()[get_fleet_data()['name'] == name].iloc[0]
74
- return f"**{v['name']}** is cruising at **{v['speed']} knots**. ETA: On Time."
75
 
76
- vessel_select.change(get_status, inputs=vessel_select, outputs=status_out)
 
 
 
 
 
 
77
 
78
- if __name__ == "__main__":
79
- demo.launch()
 
1
  import gradio as gr
2
  import pandas as pd
 
 
3
 
4
+ # Mock database of "Sea-Pass" subscribers and vessel intelligence
5
+ SUBSCRIBERS = {"user_777": {"status": "Active", "tier": "Plus"}}
 
 
 
 
 
 
 
 
 
6
 
7
+ VESSEL_INTEL = {
8
+ "Ice-9": {"load": "85% Full", "eta": "14:20", "speed": "12 kts", "contact": "7781552"},
9
+ "Kinaaraa": {"load": "4 Seats Left", "eta": "15:05", "speed": "32 kts", "contact": "7776406"},
10
+ "Island 1": {"load": "Boarding Now", "eta": "13:50", "speed": "34 kts", "contact": "7772658"}
11
+ }
12
+
13
+ def get_premium_intel(vessel_name, user_id):
14
+ """
15
+ Checks subscription status and returns high-value vessel data.
16
+ """
17
+ user = SUBSCRIBERS.get(user_id, {"status": "Free"})
18
 
19
+ if user['status'] != "Active":
20
+ return "πŸ”’ UPGRADE REQUIRED: Pay 50 MVR/mo for Live ETA & Load Data."
21
 
22
+ data = VESSEL_INTEL.get(vessel_name, "Data Unavailable")
23
+ return f"βœ… PREMIUM INTEL for {vessel_name}:\n- Load: {data['load']}\n- Speed: {data['speed']}\n- Direct Line: {data['contact']}"
 
 
 
 
 
 
 
 
24
 
25
+ # Futuristic "Liquid Glass" Interface Design
26
+ custom_css = """
27
+ .gradio-container { background: #0b0f19; color: #00f2ff; font-family: 'Inter', sans-serif; }
28
+ .glass-panel {
29
+ background: rgba(255, 255, 255, 0.05);
30
+ backdrop-filter: blur(15px);
31
+ border: 1px solid rgba(0, 242, 255, 0.2);
32
+ border-radius: 20px;
33
+ padding: 20px;
34
+ }
35
  """
36
 
37
+ with gr.Blocks(css=custom_css) as demo:
38
+ gr.Markdown("# 🌊 ODIGO: SEA-PASS CONTROL CENTER")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ with gr.Column(elem_classes="glass-panel"):
41
+ user_id = gr.Textbox(label="Enter User ID (Try: user_777)", placeholder="guest_001")
42
+ vessel = gr.Dropdown(choices=list(VESSEL_INTEL.keys()), label="Select Vessel")
43
+ intel_output = gr.Textbox(label="Vessel Status", interactive=False)
44
+
45
+ pay_btn = gr.Button("Fetch Live Data", variant="primary")
46
+ pay_btn.click(get_premium_intel, inputs=[vessel, user_id], outputs=intel_output)
47
 
48
+ demo.launch()