Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -209,22 +209,25 @@ def check_network_status():
|
|
209 |
def get_weather_data():
|
210 |
url = "http://openapi.seoul.go.kr:8088/77544e69764a414d363647424a655a/xml/citydata/1/5/์ ๋ฆผ์ญ"
|
211 |
try:
|
212 |
-
response = requests.get(url, timeout=
|
213 |
response.raise_for_status()
|
214 |
|
215 |
data = xmltodict.parse(response.text)
|
216 |
result = data['SeoulRtd.citydata']['CITYDATA']['WEATHER_STTS']['WEATHER_STTS']
|
217 |
|
218 |
-
|
219 |
-
|
|
|
220 |
except requests.exceptions.Timeout:
|
221 |
-
|
222 |
-
except requests.exceptions.RequestException
|
223 |
-
|
224 |
-
except Exception
|
225 |
-
|
|
|
226 |
return None
|
227 |
|
|
|
228 |
def get_background_color(pm10_value):
|
229 |
try:
|
230 |
pm10 = float(pm10_value)
|
|
|
209 |
def get_weather_data():
|
210 |
url = "http://openapi.seoul.go.kr:8088/77544e69764a414d363647424a655a/xml/citydata/1/5/์ ๋ฆผ์ญ"
|
211 |
try:
|
212 |
+
response = requests.get(url, timeout=30) # timeout ๊ฐ์ 30์ด๋ก ๋๋ฆผ
|
213 |
response.raise_for_status()
|
214 |
|
215 |
data = xmltodict.parse(response.text)
|
216 |
result = data['SeoulRtd.citydata']['CITYDATA']['WEATHER_STTS']['WEATHER_STTS']
|
217 |
|
218 |
+
if result: # ๊ฒฐ๊ณผ๊ฐ ์์ ๋๋ง ๋ฐํ
|
219 |
+
return result
|
220 |
+
|
221 |
except requests.exceptions.Timeout:
|
222 |
+
pass # timeout ์๋ฌ ๋ฉ์์ง ์ ๊ฑฐ
|
223 |
+
except requests.exceptions.RequestException:
|
224 |
+
pass # request ์๋ฌ ๋ฉ์์ง ์ ๊ฑฐ
|
225 |
+
except Exception:
|
226 |
+
pass # ๊ธฐํ ์๋ฌ ๋ฉ์์ง ์ ๊ฑฐ
|
227 |
+
|
228 |
return None
|
229 |
|
230 |
+
|
231 |
def get_background_color(pm10_value):
|
232 |
try:
|
233 |
pm10 = float(pm10_value)
|