Update App.py
Browse files
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 |
-
#
|
| 7 |
-
|
| 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 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 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 |
-
#
|
| 39 |
-
|
| 40 |
-
.gradio-container { background: #
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
"""
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 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()
|
|
|