Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -56,14 +56,15 @@ def create_weather_display(temp, condition, humidity, wind_speed, icon, hourly,
|
|
| 56 |
<div style="
|
| 57 |
background: linear-gradient(135deg, #2b2b2b 0%, #3a3a3a 100%);
|
| 58 |
padding: 40px;
|
| 59 |
-
border-radius:
|
| 60 |
-
box-shadow: 0 0
|
| 61 |
color: white;
|
| 62 |
-
font-family: '
|
| 63 |
text-align: center;
|
|
|
|
| 64 |
">
|
| 65 |
<div style="font-size: 80px; margin-bottom: 20px;">❌</div>
|
| 66 |
-
<h2 style="color:
|
| 67 |
<p style="color: #ccc; margin-top: 10px;">Please check your city name and API key</p>
|
| 68 |
</div>
|
| 69 |
"""
|
|
@@ -74,36 +75,79 @@ def create_weather_display(temp, condition, humidity, wind_speed, icon, hourly,
|
|
| 74 |
# Create main weather display
|
| 75 |
main_display = f"""
|
| 76 |
<div style="
|
| 77 |
-
background: linear-gradient(135deg, #
|
| 78 |
-
padding:
|
| 79 |
-
border-radius:
|
| 80 |
-
box-shadow: 0 0
|
| 81 |
color: white;
|
| 82 |
-
font-family: '
|
| 83 |
-
margin:
|
|
|
|
|
|
|
| 84 |
">
|
| 85 |
-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom:
|
| 86 |
-
<h2 style="color:
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
</div>
|
| 89 |
|
| 90 |
<div style="display: flex; justify-content: space-between; align-items: center;">
|
| 91 |
<div style="flex: 1;">
|
| 92 |
-
<h1 style="
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
</div>
|
| 99 |
-
<div style="
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
</div>
|
| 103 |
</div>
|
| 104 |
</div>
|
| 105 |
<div style="flex: 1; text-align: center;">
|
| 106 |
-
<div style="
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
</div>
|
| 108 |
</div>
|
| 109 |
</div>
|
|
@@ -123,15 +167,27 @@ def create_weather_display(temp, condition, humidity, wind_speed, icon, hourly,
|
|
| 123 |
<div style="
|
| 124 |
text-align: center;
|
| 125 |
flex: 1;
|
| 126 |
-
padding:
|
| 127 |
-
background: rgba(
|
| 128 |
-
border-radius:
|
| 129 |
-
margin: 0
|
|
|
|
|
|
|
|
|
|
| 130 |
">
|
| 131 |
-
<div style="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
{temp_part}
|
| 133 |
</div>
|
| 134 |
-
<div style="font-size:
|
| 135 |
{time_part}
|
| 136 |
</div>
|
| 137 |
</div>
|
|
@@ -139,16 +195,24 @@ def create_weather_display(temp, condition, humidity, wind_speed, icon, hourly,
|
|
| 139 |
|
| 140 |
hourly_html = f"""
|
| 141 |
<div style="
|
| 142 |
-
background: linear-gradient(135deg, #
|
| 143 |
-
padding:
|
| 144 |
-
border-radius:
|
| 145 |
-
box-shadow: 0 0
|
| 146 |
color: white;
|
| 147 |
-
font-family: '
|
| 148 |
-
margin-top:
|
|
|
|
|
|
|
| 149 |
">
|
| 150 |
-
<h3 style="
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
{hourly_items}
|
| 153 |
</div>
|
| 154 |
</div>
|
|
@@ -156,70 +220,127 @@ def create_weather_display(temp, condition, humidity, wind_speed, icon, hourly,
|
|
| 156 |
|
| 157 |
return main_display + hourly_html
|
| 158 |
|
| 159 |
-
# Custom CSS for
|
| 160 |
custom_css = """
|
| 161 |
body, .gradio-container {
|
| 162 |
-
background
|
| 163 |
color: white !important;
|
|
|
|
| 164 |
}
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
|
|
|
| 168 |
color: white !important;
|
| 169 |
-
border:
|
| 170 |
-
border-radius:
|
| 171 |
-
padding:
|
| 172 |
-
font-size:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
}
|
| 174 |
|
| 175 |
-
.
|
| 176 |
-
border-color:
|
| 177 |
-
box-shadow: 0 0 0
|
|
|
|
|
|
|
| 178 |
}
|
| 179 |
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
border: none !important;
|
| 183 |
-
padding:
|
| 184 |
-
border-radius:
|
| 185 |
font-weight: 600 !important;
|
| 186 |
font-size: 16px !important;
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
}
|
| 189 |
|
| 190 |
-
|
| 191 |
-
transform: translateY(-
|
| 192 |
-
box-shadow: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
}
|
| 194 |
|
| 195 |
.gradio-html {
|
| 196 |
background: transparent !important;
|
| 197 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
"""
|
| 199 |
|
| 200 |
# Create Gradio interface
|
| 201 |
with gr.Blocks(css=custom_css, title="Weather Wizard", theme=gr.themes.Glass()) as app:
|
| 202 |
gr.HTML("""
|
| 203 |
-
<div style="
|
| 204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
🌦️ Weather Wizard
|
| 206 |
</h1>
|
| 207 |
-
<p style="
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
</p>
|
| 210 |
</div>
|
| 211 |
""")
|
| 212 |
|
| 213 |
-
with gr.Row():
|
| 214 |
-
with gr.Column(scale=
|
| 215 |
city = gr.Textbox(
|
| 216 |
label="",
|
| 217 |
-
placeholder="
|
| 218 |
container=False,
|
| 219 |
-
elem_classes=["
|
|
|
|
| 220 |
)
|
| 221 |
with gr.Column(scale=1):
|
| 222 |
-
btn = gr.Button(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
|
| 224 |
# Weather Display
|
| 225 |
weather_display = gr.HTML()
|
|
|
|
| 56 |
<div style="
|
| 57 |
background: linear-gradient(135deg, #2b2b2b 0%, #3a3a3a 100%);
|
| 58 |
padding: 40px;
|
| 59 |
+
border-radius: 24px;
|
| 60 |
+
box-shadow: 0 0 40px rgba(203,77,11,0.2);
|
| 61 |
color: white;
|
| 62 |
+
font-family: 'Inter', 'SF Pro Display', sans-serif;
|
| 63 |
text-align: center;
|
| 64 |
+
border: 1px solid rgba(203,77,11,0.2);
|
| 65 |
">
|
| 66 |
<div style="font-size: 80px; margin-bottom: 20px;">❌</div>
|
| 67 |
+
<h2 style="color: rgb(203,77,11); margin: 0;">{temp}</h2>
|
| 68 |
<p style="color: #ccc; margin-top: 10px;">Please check your city name and API key</p>
|
| 69 |
</div>
|
| 70 |
"""
|
|
|
|
| 75 |
# Create main weather display
|
| 76 |
main_display = f"""
|
| 77 |
<div style="
|
| 78 |
+
background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
|
| 79 |
+
padding: 48px;
|
| 80 |
+
border-radius: 24px;
|
| 81 |
+
box-shadow: 0 0 50px rgba(203,77,11,0.15), 0 20px 40px rgba(0,0,0,0.3);
|
| 82 |
color: white;
|
| 83 |
+
font-family: 'Inter', 'SF Pro Display', sans-serif;
|
| 84 |
+
margin: 24px 0;
|
| 85 |
+
border: 1px solid rgba(203,77,11,0.2);
|
| 86 |
+
backdrop-filter: blur(20px);
|
| 87 |
">
|
| 88 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 36px;">
|
| 89 |
+
<h2 style="color: rgb(203,77,11); font-size: 32px; margin: 0; font-weight: 700; letter-spacing: -0.5px;">
|
| 90 |
+
🌦 Weather Wizard
|
| 91 |
+
</h2>
|
| 92 |
+
<div style="
|
| 93 |
+
color: white;
|
| 94 |
+
font-size: 28px;
|
| 95 |
+
font-weight: 600;
|
| 96 |
+
background: linear-gradient(135deg, rgba(203,77,11,0.2) 0%, rgba(255,140,60,0.1) 100%);
|
| 97 |
+
padding: 12px 24px;
|
| 98 |
+
border-radius: 16px;
|
| 99 |
+
border: 1px solid rgba(203,77,11,0.3);
|
| 100 |
+
">
|
| 101 |
+
📍 {city.title()}
|
| 102 |
+
</div>
|
| 103 |
</div>
|
| 104 |
|
| 105 |
<div style="display: flex; justify-content: space-between; align-items: center;">
|
| 106 |
<div style="flex: 1;">
|
| 107 |
+
<h1 style="
|
| 108 |
+
font-size: 84px;
|
| 109 |
+
margin: 0;
|
| 110 |
+
font-weight: 200;
|
| 111 |
+
background: linear-gradient(135deg, white 0%, rgba(203,77,11,0.8) 100%);
|
| 112 |
+
-webkit-background-clip: text;
|
| 113 |
+
-webkit-text-fill-color: transparent;
|
| 114 |
+
background-clip: text;
|
| 115 |
+
letter-spacing: -2px;
|
| 116 |
+
">{temp_display}°C</h1>
|
| 117 |
+
<p style="font-size: 28px; margin: 12px 0 0 0; color: #e0e0e0; font-weight: 500;">{condition}</p>
|
| 118 |
+
<div style="margin-top: 32px; display: flex; gap: 48px; font-size: 20px;">
|
| 119 |
+
<div style="
|
| 120 |
+
display: flex;
|
| 121 |
+
align-items: center;
|
| 122 |
+
gap: 12px;
|
| 123 |
+
background: rgba(203,77,11,0.1);
|
| 124 |
+
padding: 12px 20px;
|
| 125 |
+
border-radius: 12px;
|
| 126 |
+
border: 1px solid rgba(203,77,11,0.2);
|
| 127 |
+
">
|
| 128 |
+
<span style="font-size: 24px;">💨</span>
|
| 129 |
+
<span style="font-weight: 600;">{wind_speed} m/s</span>
|
| 130 |
</div>
|
| 131 |
+
<div style="
|
| 132 |
+
display: flex;
|
| 133 |
+
align-items: center;
|
| 134 |
+
gap: 12px;
|
| 135 |
+
background: rgba(203,77,11,0.1);
|
| 136 |
+
padding: 12px 20px;
|
| 137 |
+
border-radius: 12px;
|
| 138 |
+
border: 1px solid rgba(203,77,11,0.2);
|
| 139 |
+
">
|
| 140 |
+
<span style="font-size: 24px;">💧</span>
|
| 141 |
+
<span style="font-weight: 600;">{humidity}%</span>
|
| 142 |
</div>
|
| 143 |
</div>
|
| 144 |
</div>
|
| 145 |
<div style="flex: 1; text-align: center;">
|
| 146 |
+
<div style="
|
| 147 |
+
font-size: 140px;
|
| 148 |
+
margin: 20px 0;
|
| 149 |
+
filter: drop-shadow(0 0 20px rgba(203,77,11,0.3));
|
| 150 |
+
">{icon}</div>
|
| 151 |
</div>
|
| 152 |
</div>
|
| 153 |
</div>
|
|
|
|
| 167 |
<div style="
|
| 168 |
text-align: center;
|
| 169 |
flex: 1;
|
| 170 |
+
padding: 20px 10px;
|
| 171 |
+
background: linear-gradient(135deg, rgba(203,77,11,0.1) 0%, rgba(255,140,60,0.05) 100%);
|
| 172 |
+
border-radius: 16px;
|
| 173 |
+
margin: 0 4px;
|
| 174 |
+
border: 1px solid rgba(203,77,11,0.2);
|
| 175 |
+
transition: all 0.3s ease;
|
| 176 |
+
backdrop-filter: blur(10px);
|
| 177 |
">
|
| 178 |
+
<div style="
|
| 179 |
+
font-size: 22px;
|
| 180 |
+
font-weight: 700;
|
| 181 |
+
margin-bottom: 12px;
|
| 182 |
+
color: white;
|
| 183 |
+
background: linear-gradient(135deg, white 0%, rgb(203,77,11) 100%);
|
| 184 |
+
-webkit-background-clip: text;
|
| 185 |
+
-webkit-text-fill-color: transparent;
|
| 186 |
+
background-clip: text;
|
| 187 |
+
">
|
| 188 |
{temp_part}
|
| 189 |
</div>
|
| 190 |
+
<div style="font-size: 16px; color: #ccc; font-weight: 500;">
|
| 191 |
{time_part}
|
| 192 |
</div>
|
| 193 |
</div>
|
|
|
|
| 195 |
|
| 196 |
hourly_html = f"""
|
| 197 |
<div style="
|
| 198 |
+
background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
|
| 199 |
+
padding: 36px;
|
| 200 |
+
border-radius: 24px;
|
| 201 |
+
box-shadow: 0 0 50px rgba(203,77,11,0.15), 0 20px 40px rgba(0,0,0,0.3);
|
| 202 |
color: white;
|
| 203 |
+
font-family: 'Inter', 'SF Pro Display', sans-serif;
|
| 204 |
+
margin-top: 24px;
|
| 205 |
+
border: 1px solid rgba(203,77,11,0.2);
|
| 206 |
+
backdrop-filter: blur(20px);
|
| 207 |
">
|
| 208 |
+
<h3 style="
|
| 209 |
+
margin: 0 0 24px 0;
|
| 210 |
+
color: rgb(203,77,11);
|
| 211 |
+
font-size: 24px;
|
| 212 |
+
font-weight: 700;
|
| 213 |
+
letter-spacing: -0.5px;
|
| 214 |
+
">📊 Hourly Forecast</h3>
|
| 215 |
+
<div style="display: flex; gap: 8px; justify-content: space-between;">
|
| 216 |
{hourly_items}
|
| 217 |
</div>
|
| 218 |
</div>
|
|
|
|
| 220 |
|
| 221 |
return main_display + hourly_html
|
| 222 |
|
| 223 |
+
# Custom CSS for 2025 orange theme
|
| 224 |
custom_css = """
|
| 225 |
body, .gradio-container {
|
| 226 |
+
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%) !important;
|
| 227 |
color: white !important;
|
| 228 |
+
font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 229 |
}
|
| 230 |
|
| 231 |
+
/* Modern search bar styling */
|
| 232 |
+
.search-container input {
|
| 233 |
+
background: linear-gradient(135deg, rgba(203,77,11,0.1) 0%, rgba(255,140,60,0.05) 100%) !important;
|
| 234 |
color: white !important;
|
| 235 |
+
border: 2px solid rgba(203,77,11,0.3) !important;
|
| 236 |
+
border-radius: 16px !important;
|
| 237 |
+
padding: 16px 24px !important;
|
| 238 |
+
font-size: 18px !important;
|
| 239 |
+
font-weight: 500 !important;
|
| 240 |
+
backdrop-filter: blur(10px) !important;
|
| 241 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 242 |
+
box-shadow: 0 8px 32px rgba(203,77,11,0.1) !important;
|
| 243 |
}
|
| 244 |
|
| 245 |
+
.search-container input:focus {
|
| 246 |
+
border-color: rgb(203,77,11) !important;
|
| 247 |
+
box-shadow: 0 0 0 4px rgba(203,77,11,0.2), 0 12px 40px rgba(203,77,11,0.15) !important;
|
| 248 |
+
background: linear-gradient(135deg, rgba(203,77,11,0.15) 0%, rgba(255,140,60,0.08) 100%) !important;
|
| 249 |
+
transform: translateY(-1px) !important;
|
| 250 |
}
|
| 251 |
|
| 252 |
+
.search-container input::placeholder {
|
| 253 |
+
color: rgba(255,255,255,0.6) !important;
|
| 254 |
+
font-weight: 400 !important;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
/* 2025 Modern Button */
|
| 258 |
+
.modern-button {
|
| 259 |
+
background: linear-gradient(135deg, rgb(203,77,11) 0%, #ff6b35 100%) !important;
|
| 260 |
border: none !important;
|
| 261 |
+
padding: 16px 32px !important;
|
| 262 |
+
border-radius: 16px !important;
|
| 263 |
font-weight: 600 !important;
|
| 264 |
font-size: 16px !important;
|
| 265 |
+
letter-spacing: 0.5px !important;
|
| 266 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 267 |
+
box-shadow: 0 8px 32px rgba(203,77,11,0.25) !important;
|
| 268 |
+
position: relative !important;
|
| 269 |
+
overflow: hidden !important;
|
| 270 |
+
color: white !important;
|
| 271 |
}
|
| 272 |
|
| 273 |
+
.modern-button:hover {
|
| 274 |
+
transform: translateY(-3px) !important;
|
| 275 |
+
box-shadow: 0 16px 40px rgba(203,77,11,0.4) !important;
|
| 276 |
+
background: linear-gradient(135deg, #e8550d 0%, #ff7c47 100%) !important;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.modern-button:active {
|
| 280 |
+
transform: translateY(-1px) !important;
|
| 281 |
}
|
| 282 |
|
| 283 |
.gradio-html {
|
| 284 |
background: transparent !important;
|
| 285 |
}
|
| 286 |
+
|
| 287 |
+
/* Enhanced container styling */
|
| 288 |
+
.gradio-container {
|
| 289 |
+
background: radial-gradient(ellipse at top, rgba(203,77,11,0.1) 0%, transparent 70%) !important;
|
| 290 |
+
}
|
| 291 |
"""
|
| 292 |
|
| 293 |
# Create Gradio interface
|
| 294 |
with gr.Blocks(css=custom_css, title="Weather Wizard", theme=gr.themes.Glass()) as app:
|
| 295 |
gr.HTML("""
|
| 296 |
+
<div style="
|
| 297 |
+
text-align: center;
|
| 298 |
+
padding: 32px;
|
| 299 |
+
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
|
| 300 |
+
border-bottom: 1px solid rgba(203,77,11,0.2);
|
| 301 |
+
">
|
| 302 |
+
<h1 style="
|
| 303 |
+
color: rgb(203,77,11);
|
| 304 |
+
font-size: 42px;
|
| 305 |
+
margin: 0;
|
| 306 |
+
font-family: 'Inter', 'SF Pro Display', sans-serif;
|
| 307 |
+
font-weight: 800;
|
| 308 |
+
letter-spacing: -1px;
|
| 309 |
+
background: linear-gradient(135deg, rgb(203,77,11) 0%, #ff8c3c 100%);
|
| 310 |
+
-webkit-background-clip: text;
|
| 311 |
+
-webkit-text-fill-color: transparent;
|
| 312 |
+
background-clip: text;
|
| 313 |
+
">
|
| 314 |
🌦️ Weather Wizard
|
| 315 |
</h1>
|
| 316 |
+
<p style="
|
| 317 |
+
color: rgba(255,255,255,0.7);
|
| 318 |
+
font-size: 20px;
|
| 319 |
+
margin: 12px 0 0 0;
|
| 320 |
+
font-weight: 400;
|
| 321 |
+
letter-spacing: 0.5px;
|
| 322 |
+
">
|
| 323 |
+
AI-powered weather forecasts for the modern world
|
| 324 |
</p>
|
| 325 |
</div>
|
| 326 |
""")
|
| 327 |
|
| 328 |
+
with gr.Row(elem_classes=["search-row"]):
|
| 329 |
+
with gr.Column(scale=3):
|
| 330 |
city = gr.Textbox(
|
| 331 |
label="",
|
| 332 |
+
placeholder="Search any city worldwide... (e.g. New York, Tokyo, London)",
|
| 333 |
container=False,
|
| 334 |
+
elem_classes=["search-container"],
|
| 335 |
+
show_label=False
|
| 336 |
)
|
| 337 |
with gr.Column(scale=1):
|
| 338 |
+
btn = gr.Button(
|
| 339 |
+
"✨ Discover Weather",
|
| 340 |
+
variant="primary",
|
| 341 |
+
size="lg",
|
| 342 |
+
elem_classes=["modern-button"]
|
| 343 |
+
)
|
| 344 |
|
| 345 |
# Weather Display
|
| 346 |
weather_display = gr.HTML()
|