mohitk1234 commited on
Commit
5a4fc3e
·
verified ·
1 Parent(s): a593206

whetherapp

Browse files
Files changed (1) hide show
  1. app.py +69 -0
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def get_weather_data(city):
4
+ # Simulated values — replace with real API later
5
+ temp_c = 42
6
+ temp_f = round(temp_c * 9 / 5 + 32, 1)
7
+ pressure = 1010
8
+ wind_speed = 18
9
+ wind_deg = 45
10
+ wind_direction = "NE"
11
+
12
+ return [
13
+ city.title(),
14
+ f"{temp_c} °C",
15
+ f"{temp_f} °F",
16
+ f"{pressure} hPa",
17
+ f"{wind_speed} km/h",
18
+ f"{wind_direction} ({wind_deg}°)"
19
+ ]
20
+
21
+ with gr.Blocks(theme=gr.themes.Soft(),
22
+ css="""
23
+ #city_box, #temp_c_box, #temp_f_box, #pressure_box, #wind_box, #dir_box {
24
+ background-color: #f0f8ff;
25
+ border-radius: 10px;
26
+ font-weight: bold;
27
+ padding: 10px;
28
+ }
29
+
30
+ .gr-button {
31
+ background-color: #0066cc !important;
32
+ color: white !important;
33
+ font-size: 16px !important;
34
+ border-radius: 8px !important;
35
+ padding: 12px 20px !important;
36
+ }
37
+
38
+ .gr-textbox label {
39
+ font-weight: 600;
40
+ color: #333;
41
+ }
42
+ """) as app:
43
+ gr.Markdown(
44
+ """
45
+ <h1 style='text-align:center; color:#0066cc;'>🌦️ <span style="color:#333">UAE Weather Dashboard</span></h1>
46
+ <p style='text-align:center; font-size:16px;'>Type in your city to get the latest weather insights!</p>
47
+ """)
48
+
49
+ with gr.Row():
50
+ city_input = gr.Textbox(label="🏙️ City", placeholder="e.g., Dubai")
51
+
52
+ get_weather_btn = gr.Button("🔍 Get Weather")
53
+
54
+ with gr.Row():
55
+ with gr.Column():
56
+ city_output = gr.Textbox(label="📍 City", interactive=False, show_label=True, elem_id="city_box")
57
+ temp_c_output = gr.Textbox(label="🌡️ Temperature (°C)", interactive=False, elem_id="temp_c_box")
58
+ temp_f_output = gr.Textbox(label="🌡️ Temperature (°F)", interactive=False, elem_id="temp_f_box")
59
+ with gr.Column():
60
+ pressure_output = gr.Textbox(label="💨 Pressure (hPa)", interactive=False, elem_id="pressure_box")
61
+ wind_speed_output = gr.Textbox(label="🌬️ Wind Speed", interactive=False, elem_id="wind_box")
62
+ wind_dir_output = gr.Textbox(label="🧭 Wind Direction", interactive=False, elem_id="dir_box")
63
+
64
+ get_weather_btn.click(get_weather_data, inputs=[city_input], outputs=[
65
+ city_output, temp_c_output, temp_f_output, pressure_output, wind_speed_output, wind_dir_output
66
+ ])
67
+
68
+
69
+ app.launch(share=True)