Spaces:
Sleeping
Sleeping
rickyt
commited on
Commit
·
e4a3592
1
Parent(s):
042d0c5
change to 24
Browse files
app.py
CHANGED
|
@@ -68,7 +68,7 @@ def fetch_hourly_table(location: str):
|
|
| 68 |
return None, "⚠️ Unexpected response format or no periods returned."
|
| 69 |
|
| 70 |
rec = records[0]
|
| 71 |
-
periods = (rec.get("periods") or [])[:
|
| 72 |
if not periods:
|
| 73 |
return None, "⚠️ No hourly periods returned."
|
| 74 |
|
|
@@ -94,7 +94,7 @@ def fetch_hourly_table(location: str):
|
|
| 94 |
|
| 95 |
rows.append({
|
| 96 |
"Time": dt.strftime("%Y-%m-%d %H:%M %Z") if isinstance(dt, pd.Timestamp) else iso,
|
| 97 |
-
"Weather": p.get("
|
| 98 |
"Temp (°C)": p.get("tempC") if p.get("tempC") is not None else p.get("avgTempC"),
|
| 99 |
"Feels (°C)": p.get("feelslikeC") if p.get("feelslikeC") is not None else p.get("avgFeelslikeC"),
|
| 100 |
"Humidity (%)": p.get("humidity"),
|
|
@@ -112,12 +112,12 @@ def fetch_hourly_table(location: str):
|
|
| 112 |
place_str = ", ".join([x for x in [place.get("name"), place.get("state"), place.get("country")] if x])
|
| 113 |
loc_str = f"**Location**: {place_str or location}"
|
| 114 |
tz_info = f" • **Timezone**: {tz_str}" if tz_str else ""
|
| 115 |
-
meta = f"{loc_str}{tz_info} • Periods: {len(df)} (filter=1hr, limit=
|
| 116 |
|
| 117 |
return df, meta
|
| 118 |
|
| 119 |
with gr.Blocks(fill_height=True) as demo:
|
| 120 |
-
gr.Markdown("## Xweather — Hourly Forecast (Next
|
| 121 |
with gr.Row():
|
| 122 |
loc = gr.Textbox(
|
| 123 |
label="Location",
|
|
|
|
| 68 |
return None, "⚠️ Unexpected response format or no periods returned."
|
| 69 |
|
| 70 |
rec = records[0]
|
| 71 |
+
periods = (rec.get("periods") or [])[:24]
|
| 72 |
if not periods:
|
| 73 |
return None, "⚠️ No hourly periods returned."
|
| 74 |
|
|
|
|
| 94 |
|
| 95 |
rows.append({
|
| 96 |
"Time": dt.strftime("%Y-%m-%d %H:%M %Z") if isinstance(dt, pd.Timestamp) else iso,
|
| 97 |
+
"Weather": p.get("weather") or p.get("weatherPrimary"),
|
| 98 |
"Temp (°C)": p.get("tempC") if p.get("tempC") is not None else p.get("avgTempC"),
|
| 99 |
"Feels (°C)": p.get("feelslikeC") if p.get("feelslikeC") is not None else p.get("avgFeelslikeC"),
|
| 100 |
"Humidity (%)": p.get("humidity"),
|
|
|
|
| 112 |
place_str = ", ".join([x for x in [place.get("name"), place.get("state"), place.get("country")] if x])
|
| 113 |
loc_str = f"**Location**: {place_str or location}"
|
| 114 |
tz_info = f" • **Timezone**: {tz_str}" if tz_str else ""
|
| 115 |
+
meta = f"{loc_str}{tz_info} • Periods: {len(df)} (filter=1hr, limit=24)"
|
| 116 |
|
| 117 |
return df, meta
|
| 118 |
|
| 119 |
with gr.Blocks(fill_height=True) as demo:
|
| 120 |
+
gr.Markdown("## Xweather — Hourly Forecast (Next 24 Hours)")
|
| 121 |
with gr.Row():
|
| 122 |
loc = gr.Textbox(
|
| 123 |
label="Location",
|