JAMESPARK3 commited on
Commit
0b81a5d
ยท
verified ยท
1 Parent(s): 31bd761

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
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=10) # 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
- return result
219
-
 
220
  except requests.exceptions.Timeout:
221
- st.error("API ์š”์ฒญ ์‹œ๊ฐ„์ด ์ดˆ๊ณผ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
222
- except requests.exceptions.RequestException as e:
223
- st.error(f"API ํ˜ธ์ถœ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}")
224
- except Exception as e:
225
- st.error(f"๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}")
 
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)