jeongsoo commited on
Commit
63f77d7
ยท
1 Parent(s): b8d7ba7
Files changed (2) hide show
  1. app.py +5 -5
  2. app/app_device_routes.py +3 -3
app.py CHANGED
@@ -25,9 +25,9 @@ try:
25
  # CORS ์„ค์ •
26
  CORS(app, supports_credentials=True)
27
 
28
- # ์žฅ์น˜ ์„œ๋ฒ„ URL ํ™˜๊ฒฝ ๋ณ€์ˆ˜
29
- device_server_url = os.getenv('DEVICE_SERVER_URL', 'http://localhost:5050')
30
- logger.info(f"์žฅ์น˜ ์„œ๋ฒ„ URL: {device_server_url}")
31
 
32
  # ์ธ์ฆ ๋ฐ์ฝ”๋ ˆ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
33
  from app.app import login_required
@@ -48,8 +48,8 @@ try:
48
  return login_required(f)(*args, **kwargs)
49
  return decorated_function
50
 
51
- # ์žฅ์น˜ ๋ผ์šฐํŠธ ๋“ฑ๋ก
52
- register_device_routes(app, device_login_required, device_server_url)
53
  logger.info("์žฅ์น˜ ๋ผ์šฐํŠธ ์ง์ ‘ ๋“ฑ๋ก ์„ฑ๊ณต")
54
 
55
  # 404 ์˜ค๋ฅ˜ ํ•ธ๋“ค๋Ÿฌ ๋“ฑ๋ก
 
25
  # CORS ์„ค์ •
26
  CORS(app, supports_credentials=True)
27
 
28
+ # ์žฅ์น˜ ์„œ๋ฒ„ URL ํ™˜๊ฒฝ ๋ณ€์ˆ˜ (๋Œ€๋ฌธ์ž๋กœ ๋ณ€๊ฒฝ)
29
+ DEVICE_SERVER_URL = os.getenv('DEVICE_SERVER_URL', 'http://localhost:5050')
30
+ logger.info(f"์žฅ์น˜ ์„œ๋ฒ„ URL: {DEVICE_SERVER_URL}")
31
 
32
  # ์ธ์ฆ ๋ฐ์ฝ”๋ ˆ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
33
  from app.app import login_required
 
48
  return login_required(f)(*args, **kwargs)
49
  return decorated_function
50
 
51
+ # ์žฅ์น˜ ๋ผ์šฐํŠธ ๋“ฑ๋ก (๋Œ€๋ฌธ์ž ๋ณ€์ˆ˜๋ช… ์‚ฌ์šฉ)
52
+ register_device_routes(app, device_login_required, DEVICE_SERVER_URL)
53
  logger.info("์žฅ์น˜ ๋ผ์šฐํŠธ ์ง์ ‘ ๋“ฑ๋ก ์„ฑ๊ณต")
54
 
55
  # 404 ์˜ค๋ฅ˜ ํ•ธ๋“ค๋Ÿฌ ๋“ฑ๋ก
app/app_device_routes.py CHANGED
@@ -23,8 +23,8 @@ def register_device_routes(app, login_required, DEVICE_SERVER_URL):
23
  timeout = 5 # 5์ดˆ๋กœ ํƒ€์ž„์•„์›ƒ ์„ค์ •
24
 
25
  try:
26
- # ์žฅ์น˜ ์„œ๋ฒ„ ์ƒํƒœ ํ™•์ธ
27
- response = requests.get(f"{device_server_url}/status", timeout=timeout)
28
 
29
  if response.status_code == 200:
30
  return jsonify({"success": True, "status": "connected", "data": response.json()})
@@ -198,4 +198,4 @@ def register_device_routes(app, login_required, DEVICE_SERVER_URL):
198
  return jsonify({
199
  "success": False,
200
  "error": f"ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
201
- }), 500
 
23
  timeout = 5 # 5์ดˆ๋กœ ํƒ€์ž„์•„์›ƒ ์„ค์ •
24
 
25
  try:
26
+ # ์žฅ์น˜ ์„œ๋ฒ„ ์ƒํƒœ ํ™•์ธ - DEVICE_SERVER_URL ๋ณ€์ˆ˜ ์‚ฌ์šฉ (๋Œ€๋ฌธ์ž)
27
+ response = requests.get(f"{DEVICE_SERVER_URL}/status", timeout=timeout)
28
 
29
  if response.status_code == 200:
30
  return jsonify({"success": True, "status": "connected", "data": response.json()})
 
198
  return jsonify({
199
  "success": False,
200
  "error": f"ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
201
+ }), 500