Spaces:
Sleeping
Sleeping
File size: 18,378 Bytes
460bd69 17f5a8a 460bd69 7cef4b0 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a d3f3344 17f5a8a d3f3344 7cef4b0 17f5a8a 7cef4b0 17f5a8a d3f3344 17f5a8a d3f3344 17f5a8a d3f3344 17f5a8a d3f3344 17f5a8a d3f3344 17f5a8a 460bd69 d3f3344 17f5a8a d3f3344 7cef4b0 460bd69 17f5a8a d3f3344 17f5a8a d3f3344 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a d3f3344 17f5a8a 460bd69 17f5a8a 460bd69 7cef4b0 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 7cef4b0 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 7cef4b0 460bd69 7cef4b0 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 17f5a8a 460bd69 63f77d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
"""
RAG ๊ฒ์ ์ฑ๋ด ์น ์ ํ๋ฆฌ์ผ์ด์
- ์ฅ์น ๊ด๋ฆฌ API ๋ผ์ฐํธ ์ ์ (API ๊ฒฝ๋ก ์์ ๋จ)
"""
import logging
import requests
from flask import request, jsonify
# ๋ก๊ฑฐ ๊ฐ์ ธ์ค๊ธฐ
logger = logging.getLogger(__name__)
def register_device_routes(app, login_required, DEVICE_SERVER_URL):
"""Flask ์ ํ๋ฆฌ์ผ์ด์
์ ์ฅ์น ๊ด๋ฆฌ ๊ด๋ จ ๋ผ์ฐํธ ๋ฑ๋ก"""
# ์ฌ์ฉ์ ์ง์ ์ฅ์น ์๋ฒ URL ๋ณ์
custom_device_url = None
# URL ์ค์ ํจ์
def get_device_url():
# ์ฌ์ฉ์ ์ง์ URL์ด ์์ผ๋ฉด ์ฌ์ฉ, ์์ผ๋ฉด ํ๊ฒฝ๋ณ์ ๊ฐ ์ฌ์ฉ
return custom_device_url or DEVICE_SERVER_URL
@app.route('/api/device/connect', methods=['POST'])
@login_required
def connect_device_server():
"""์ฌ์ฉ์ ์ง์ ์ฅ์น ์๋ฒ URL ์ฐ๊ฒฐ API"""
nonlocal custom_device_url # ์์ ์ค์ฝํ์ ๋ณ์ ์ฐธ์กฐ
try:
# ์์ฒญ์์ URL ๊ฐ์ ธ์ค๊ธฐ
request_data = request.get_json()
if not request_data or 'url' not in request_data:
logger.error("URL์ด ์ ๊ณต๋์ง ์์์ต๋๋ค.")
return jsonify({
"success": False,
"error": "URL์ด ์ ๊ณต๋์ง ์์์ต๋๋ค."
}), 400 # Bad Request
new_url = request_data['url'].strip()
if not new_url:
logger.error("URL์ด ๋น์ด ์์ต๋๋ค.")
return jsonify({
"success": False,
"error": "URL์ด ๋น์ด ์์ต๋๋ค."
}), 400 # Bad Request
# URL ์ค์
logger.info(f"์ฌ์ฉ์ ์ง์ ์ฅ์น ์๋ฒ URL ์ค์ : {new_url}")
custom_device_url = new_url
# ์ค์ ๋ URL๋ก ์ํ ํ์ธ ์๋
try:
api_path = "/api/status"
logger.info(f"์ฅ์น ์๋ฒ ์ํ ํ์ธ ์์ฒญ: {custom_device_url}{api_path}")
response = requests.get(f"{custom_device_url}{api_path}", timeout=5)
if response.status_code == 200:
try:
data = response.json()
logger.info(f"์ฌ์ฉ์ ์ง์ ์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ฑ๊ณต. ์๋ต ๋ฐ์ดํฐ: {data}")
return jsonify({
"success": True,
"message": "์ฅ์น ์๋ฒ ์ฐ๊ฒฐ์ ์ฑ๊ณตํ์ต๋๋ค.",
"server_status": data.get("status", "์ ์")
})
except requests.exceptions.JSONDecodeError:
logger.error("์ฅ์น ์๋ฒ ์๋ต JSON ํ์ฑ ์คํจ")
return jsonify({
"success": False,
"error": "์ฅ์น ์๋ฒ๋ก๋ถํฐ ์ ํจํ์ง ์์ JSON ์๋ต์ ๋ฐ์์ต๋๋ค."
}), 502 # Bad Gateway
else:
error_message = f"์ฅ์น ์๋ฒ ์๋ต ์ค๋ฅ: {response.status_code}"
try:
error_detail = response.json().get("error", response.text)
error_message += f" - {error_detail}"
except Exception:
error_message += f" - {response.text}"
logger.warning(error_message)
custom_device_url = None # ์ฐ๊ฒฐ ์คํจ ์ URL ์ด๊ธฐํ
return jsonify({
"success": False,
"error": error_message
}), 502 # Bad Gateway
except requests.exceptions.Timeout:
logger.error(f"์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ํ์์์ ({custom_device_url})")
custom_device_url = None # ์ฐ๊ฒฐ ์คํจ ์ URL ์ด๊ธฐํ
return jsonify({
"success": False,
"error": "์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ํ์์์. ์๋ฒ ์๋ต์ด ๋๋ฌด ๋๋ฆฝ๋๋ค."
}), 504 # Gateway Timeout
except requests.exceptions.ConnectionError:
logger.error(f"์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์คํจ ({custom_device_url})")
custom_device_url = None # ์ฐ๊ฒฐ ์คํจ ์ URL ์ด๊ธฐํ
return jsonify({
"success": False,
"error": "์ฅ์น ๊ด๋ฆฌ ์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง, URL์ด ์ ํํ์ง ํ์ธํด์ฃผ์ธ์."
}), 502 # Bad Gateway
except Exception as e:
logger.error(f"์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ค ์์์น ๋ชปํ ์ค๋ฅ ๋ฐ์: {e}", exc_info=True)
custom_device_url = None # ์ฐ๊ฒฐ ์คํจ ์ URL ์ด๊ธฐํ
return jsonify({
"success": False,
"error": f"์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
}), 500 # Internal Server Error
except Exception as e:
logger.error(f"/api/device/connect ์ฒ๋ฆฌ ์ค ๋ด๋ถ ์๋ฒ ์ค๋ฅ: {e}", exc_info=True)
return jsonify({
"success": False,
"error": f"๋ด๋ถ ์๋ฒ ์ค๋ฅ ๋ฐ์: {str(e)}"
}), 500 # Internal Server Error
@app.route('/api/device/status', methods=['GET'])
@login_required
def device_status():
"""์ฅ์น ๊ด๋ฆฌ ์๋ฒ์ ์ํ๋ฅผ ํ์ธํ๋ API ์๋ํฌ์ธํธ"""
try:
# requests ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ํจ์ ๋ด์์ ์ํฌํธํ ํ์ ์์ (์๋จ ์ํฌํธ ์ฌ์ฉ)
# json, jsonify๋ Flask์์ ์ด๋ฏธ ์ํฌํธ๋จ (์๋จ ์ํฌํธ ์ฌ์ฉ)
# ์ฐ๊ฒฐ ํ์์์ ์ค์
timeout = 5 # 5์ด๋ก ํ์์์ ์ค์
try:
# ์ฅ์น ์๋ฒ ์ํ ํ์ธ - ๊ฒฝ๋ก: /api/status
current_device_url = get_device_url()
api_path = "/api/status"
logger.info(f"์ฅ์น ์๋ฒ ์ํ ํ์ธ ์์ฒญ: {current_device_url}{api_path}")
response = requests.get(f"{current_device_url}{api_path}", timeout=timeout)
# ์๋ต ์ํ ์ฝ๋ ๋ฐ ๋ด์ฉ ๋ก๊น
(๋๋ฒ๊น
๊ฐํ)
logger.debug(f"์ฅ์น ์๋ฒ ์๋ต ์ํ ์ฝ๋: {response.status_code}")
try:
logger.debug(f"์ฅ์น ์๋ฒ ์๋ต ๋ด์ฉ: {response.text[:200]}...") # ๋๋ฌด ๊ธธ๋ฉด ์๋ผ์ ๋ก๊น
except Exception:
logger.debug("์ฅ์น ์๋ฒ ์๋ต ๋ด์ฉ ๋ก๊น
์คํจ (ํ
์คํธ ํ์ ์๋?)")
if response.status_code == 200:
# ์ฑ๊ณต ์ ์๋ต ๋ฐ์ดํฐ ๊ตฌ์กฐ ํ์ธ ๋ฐ ๋ก๊น
try:
data = response.json()
logger.info(f"์ฅ์น ์๋ฒ ์ํ ํ์ธ ์ฑ๊ณต. ์๋ต ๋ฐ์ดํฐ: {data}")
return jsonify({"success": True, "status": "connected", "data": data})
except requests.exceptions.JSONDecodeError:
logger.error("์ฅ์น ์๋ฒ ์๋ต JSON ํ์ฑ ์คํจ")
return jsonify({
"success": False,
"error": "์ฅ์น ์๋ฒ๋ก๋ถํฐ ์ ํจํ์ง ์์ JSON ์๋ต์ ๋ฐ์์ต๋๋ค."
}), 502 # Bad Gateway (์
์คํธ๋ฆผ ์๋ฒ ์ค๋ฅ)
else:
# ์คํจ ์ ์ค๋ฅ ๋ฉ์์ง ํฌํจ ๋ก๊น
error_message = f"์ฅ์น ์๋ฒ ์๋ต ์ค๋ฅ: {response.status_code}"
try:
# ์๋ฒ์์ ์ค๋ฅ ๋ฉ์์ง๋ฅผ json์ผ๋ก ๋ณด๋ด๋ ๊ฒฝ์ฐ ํฌํจ
error_detail = response.json().get("error", response.text)
error_message += f" - {error_detail}"
except Exception:
error_message += f" - {response.text}" # JSON ํ์ฑ ์คํจ ์ ์๋ณธ ํ
์คํธ
logger.warning(error_message) # ๊ฒฝ๊ณ ๋ ๋ฒจ๋ก ๋ก๊น
return jsonify({
"success": False,
"error": error_message
}), 502 # Bad Gateway
except requests.exceptions.Timeout:
logger.error(f"์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ํ์์์ ({DEVICE_SERVER_URL})")
return jsonify({
"success": False,
"error": "์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ํ์์์. ์๋ฒ ์๋ต์ด ๋๋ฌด ๋๋ฆฝ๋๋ค."
}), 504 # Gateway Timeout
except requests.exceptions.ConnectionError:
current_device_url = get_device_url()
logger.error(f"์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์คํจ ({current_device_url})")
return jsonify({
"success": False,
"error": "์ฅ์น ๊ด๋ฆฌ ์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง, URL์ด ์ ํํ์ง ํ์ธํด์ฃผ์ธ์."
}), 502 # Bad Gateway (์ฐ๊ฒฐ ์คํจ๋ ์
์คํธ๋ฆผ ๋ฌธ์ ๋ก ๊ฐ์ฃผ)
except Exception as e:
logger.error(f"์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ค ์์์น ๋ชปํ ์ค๋ฅ ๋ฐ์: {e}", exc_info=True) # ์์ธ ์คํ ํธ๋ ์ด์ค ๋ก๊น
return jsonify({
"success": False,
"error": f"์ฅ์น ์๋ฒ ์ฐ๊ฒฐ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
}), 500 # Internal Server Error (Flask ์ฑ ๋ด๋ถ ๋๋ requests ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฌธ์ ๊ฐ๋ฅ์ฑ)
except Exception as e:
# ์ด try-except ๋ธ๋ก์ /api/device/status ๋ผ์ฐํธ ์์ฒด์ ๋ด๋ถ ์ค๋ฅ ์ฒ๋ฆฌ
logger.error(f"/api/device/status ์ฒ๋ฆฌ ์ค ๋ด๋ถ ์๋ฒ ์ค๋ฅ: {e}", exc_info=True)
return jsonify({
"success": False,
"error": f"๋ด๋ถ ์๋ฒ ์ค๋ฅ ๋ฐ์: {str(e)}"
}), 500 # Internal Server Error
@app.route('/api/device/list', methods=['GET'])
@login_required
def device_list():
"""์ฅ์น ๋ชฉ๋ก ์กฐํ API"""
logger.info("์ฅ์น ๋ชฉ๋ก ์กฐํ ์์ฒญ")
try:
current_device_url = get_device_url()
api_path = "/api/devices"
logger.info(f"์ฅ์น ๋ชฉ๋ก ์กฐํ ์์ฒญ: {current_device_url}{api_path}")
response = requests.get(f"{current_device_url}{api_path}", timeout=5)
logger.debug(f"์ฅ์น ๋ชฉ๋ก ์๋ต ์ํ ์ฝ๋: {response.status_code}")
if response.status_code == 200:
try:
data = response.json()
devices = data.get("devices", [])
logger.info(f"์ฅ์น ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต: {len(devices)}๊ฐ ์ฅ์น")
return jsonify({
"success": True,
"devices": devices
})
except requests.exceptions.JSONDecodeError:
logger.error("์ฅ์น ๋ชฉ๋ก ์๋ต JSON ํ์ฑ ์คํจ")
return jsonify({"success": False, "error": "์ฅ์น ์๋ฒ๋ก๋ถํฐ ์ ํจํ์ง ์์ JSON ์๋ต"}), 502
else:
error_message = f"์ฅ์น ๋ชฉ๋ก ์กฐํ ์คํจ: {response.status_code}"
try: error_message += f" - {response.json().get('error', response.text)}"
except Exception: error_message += f" - {response.text}"
logger.warning(error_message)
return jsonify({
"success": False,
"error": error_message
}), 502
except requests.exceptions.Timeout:
logger.error("์ฅ์น ๋ชฉ๋ก ์กฐํ ์๊ฐ ์ด๊ณผ")
return jsonify({
"success": False,
"error": "์ฅ์น ๋ชฉ๋ก ์กฐํ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค."
}), 504
except requests.exceptions.ConnectionError:
logger.error("์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์คํจ")
return jsonify({
"success": False,
"error": "์ฅ์น ๊ด๋ฆฌ ์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์."
}), 503 # Service Unavailable
except Exception as e:
logger.error(f"์ฅ์น ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: {e}", exc_info=True)
return jsonify({
"success": False,
"error": f"์ฅ์น ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
}), 500
@app.route('/api/device/programs', methods=['GET'])
@login_required
def device_programs():
"""์คํ ๊ฐ๋ฅํ ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ API"""
logger.info("ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์์ฒญ")
try:
current_device_url = get_device_url()
api_path = "/api/programs"
logger.info(f"ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์์ฒญ: {current_device_url}{api_path}")
response = requests.get(f"{current_device_url}{api_path}", timeout=5)
logger.debug(f"ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์๋ต ์ํ ์ฝ๋: {response.status_code}")
if response.status_code == 200:
try:
data = response.json()
programs = data.get("programs", [])
logger.info(f"ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต: {len(programs)}๊ฐ ํ๋ก๊ทธ๋จ")
return jsonify({
"success": True,
"programs": programs
})
except requests.exceptions.JSONDecodeError:
logger.error("ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์๋ต JSON ํ์ฑ ์คํจ")
return jsonify({"success": False, "error": "์ฅ์น ์๋ฒ๋ก๋ถํฐ ์ ํจํ์ง ์์ JSON ์๋ต"}), 502
else:
error_message = f"ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์คํจ: {response.status_code}"
try: error_message += f" - {response.json().get('error', response.text)}"
except Exception: error_message += f" - {response.text}"
logger.warning(error_message)
return jsonify({
"success": False,
"error": error_message
}), 502
except requests.exceptions.Timeout:
logger.error("ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์๊ฐ ์ด๊ณผ")
return jsonify({
"success": False,
"error": "ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค."
}), 504
except requests.exceptions.ConnectionError:
logger.error("์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์คํจ")
return jsonify({
"success": False,
"error": "์ฅ์น ๊ด๋ฆฌ ์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์."
}), 503
except Exception as e:
logger.error(f"ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: {e}", exc_info=True)
return jsonify({
"success": False,
"error": f"ํ๋ก๊ทธ๋จ ๋ชฉ๋ก ์กฐํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
}), 500
@app.route('/api/device/programs/<program_id>/execute', methods=['POST'])
@login_required
def execute_program(program_id):
"""ํ๋ก๊ทธ๋จ ์คํ API"""
logger.info(f"ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ: {program_id}")
try:
current_device_url = get_device_url()
api_path = f"/api/programs/{program_id}/execute"
logger.info(f"ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ: {current_device_url}{api_path}")
response = requests.post(
f"{current_device_url}{api_path}",
json={}, # ํ์์ ์ฌ๊ธฐ์ ํ๋ผ๋ฏธํฐ ์ถ๊ฐ ๊ฐ๋ฅ
timeout=10 # ํ๋ก๊ทธ๋จ ์คํ์๋ ๋ ๊ธด ์๊ฐ ๋ถ์ฌ
)
logger.debug(f"ํ๋ก๊ทธ๋จ ์คํ ์๋ต ์ํ ์ฝ๋: {response.status_code}")
if response.status_code == 200:
try:
data = response.json()
success = data.get("success", False)
message = data.get("message", "")
logger.info(f"ํ๋ก๊ทธ๋จ ์คํ ์๋ต: {success}, {message}")
return jsonify(data) # ์๋ฒ ์๋ต ๊ทธ๋๋ก ๋ฐํ
except requests.exceptions.JSONDecodeError:
logger.error("ํ๋ก๊ทธ๋จ ์คํ ์๋ต JSON ํ์ฑ ์คํจ")
# ์ฑ๊ณต(200)ํ์ง๋ง ์๋ต์ด ๋น์ ์์ ์ธ ๊ฒฝ์ฐ
return jsonify({
"success": False, # ํ์ฑ ์คํจํ์ผ๋ฏ๋ก False๋ก ๊ฐ์ฃผ
"error": "ํ๋ก๊ทธ๋จ ์คํ ์๋ฒ๋ก๋ถํฐ ์ ํจํ์ง ์์ JSON ์๋ต"
}), 502
else:
error_message = f"ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์คํจ: {response.status_code}"
try: error_message += f" - {response.json().get('error', response.text)}"
except Exception: error_message += f" - {response.text}"
logger.warning(error_message)
return jsonify({
"success": False,
"error": error_message
}), 502 # ๋๋ response.status_code ๋ฅผ ๊ทธ๋๋ก ๋ฐํํ๋ ๊ฒ๋ ๊ณ ๋ ค
except requests.exceptions.Timeout:
logger.error("ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์๊ฐ ์ด๊ณผ")
return jsonify({
"success": False,
"error": "ํ๋ก๊ทธ๋จ ์คํ ์์ฒญ ์๊ฐ์ด ์ด๊ณผ๋์์ต๋๋ค."
}), 504
except requests.exceptions.ConnectionError:
logger.error("์ฅ์น ๊ด๋ฆฌ ์๋ฒ ์ฐ๊ฒฐ ์คํจ")
return jsonify({
"success": False,
"error": "์ฅ์น ๊ด๋ฆฌ ์๋ฒ์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค. ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํด์ฃผ์ธ์."
}), 503
except Exception as e:
logger.error(f"ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์: {e}", exc_info=True)
return jsonify({
"success": False,
"error": f"ํ๋ก๊ทธ๋จ ์คํ ์ค ์ค๋ฅ ๋ฐ์: {str(e)}"
}), 500 |