ssboost commited on
Commit
45b8d26
ยท
verified ยท
1 Parent(s): fae476c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -4
app.py CHANGED
@@ -26,8 +26,26 @@ logger = logging.getLogger(__name__)
26
 
27
  # API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
28
  def get_client():
29
- endpoint = os.getenv('API_ENDPOINT')
30
- return Client(endpoint)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  # ์„ธ์…˜๋ณ„ ์ž„์‹œ ํŒŒ์ผ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ ๋”•์…”๋„ˆ๋ฆฌ
33
  session_temp_files = {}
@@ -194,7 +212,19 @@ def wrapper_modified(keyword, korean_only, apply_main_keyword_option, exclude_ze
194
  api_name="/process_search_results"
195
  )
196
 
197
- table_html, cat_choices, vol_choices, selected_cat, download_file = result
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
  local_file = None
200
  if download_file:
@@ -239,7 +269,18 @@ def analyze_with_auto_download(analysis_keywords, selected_category, state_df, s
239
  api_name="/process_analyze_results"
240
  )
241
 
242
- analysis_result, download_file = result
 
 
 
 
 
 
 
 
 
 
 
243
 
244
  local_file = None
245
  if download_file:
 
26
 
27
  # API ํด๋ผ์ด์–ธํŠธ ์„ค์ •
28
  def get_client():
29
+ # ํ™˜๊ฒฝ๋ณ€์ˆ˜์—์„œ API ์—”๋“œํฌ์ธํŠธ ์ฝ๊ธฐ
30
+ endpoint = os.environ.get('API_ENDPOINT', '')
31
+
32
+ # ํ™˜๊ฒฝ๋ณ€์ˆ˜์— ํŒŒ์ผ ๋‚ด์šฉ์ด๋‚˜ ๋ถˆํ•„์š”ํ•œ ํ…์ŠคํŠธ๊ฐ€ ๋“ค์–ด์˜จ ๊ฒฝ์šฐ ์ •๋ฆฌ
33
+ if endpoint:
34
+ # ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ๋ถ„๋ฆฌํ•ด์„œ ์ฒซ ๋ฒˆ์งธ ์œ ํšจํ•œ ๋ผ์ธ ์ฐพ๊ธฐ
35
+ lines = endpoint.split('\n')
36
+ for line in lines:
37
+ line = line.strip()
38
+ # ์ฃผ์„์ด๋‚˜ ๋น„์–ด์žˆ๋Š” ๋ผ์ธ ์ œ์™ธ
39
+ if line and not line.startswith('#') and '/' in line:
40
+ # API_ENDPOINT= ๊ฐ™์€ ํ‚ค๊ฐ’ ์ œ๊ฑฐ
41
+ if '=' in line:
42
+ line = line.split('=', 1)[1].strip()
43
+ # ๋”ฐ์˜ดํ‘œ ์ œ๊ฑฐ
44
+ line = line.strip('"\'')
45
+ if line and '/' in line and len(line) < 50:
46
+ return Client(line)
47
+
48
+ raise ValueError("์˜ฌ๋ฐ”๋ฅธ API_ENDPOINT๋ฅผ ์„ค์ •ํ•ด์ฃผ์„ธ์š” (์˜ˆ: username/repo-name)")
49
 
50
  # ์„ธ์…˜๋ณ„ ์ž„์‹œ ํŒŒ์ผ ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ ๋”•์…”๋„ˆ๋ฆฌ
51
  session_temp_files = {}
 
212
  api_name="/process_search_results"
213
  )
214
 
215
+ # API ์‘๋‹ต ํ™•์ธ ๋ฐ ์ฒ˜๋ฆฌ
216
+ logger.info(f"API ์‘๋‹ต ํƒ€์ž…: {type(result)}, ๊ธธ์ด: {len(result) if isinstance(result, (list, tuple)) else 'N/A'}")
217
+
218
+ if isinstance(result, (list, tuple)) and len(result) >= 5:
219
+ table_html, cat_choices, vol_choices, selected_cat, download_file = result[:5]
220
+ else:
221
+ # ์‘๋‹ต์ด ์˜ˆ์ƒ๊ณผ ๋‹ค๋ฅธ ๊ฒฝ์šฐ ๊ธฐ๋ณธ๊ฐ’ ์‚ฌ์šฉ
222
+ logger.warning(f"์˜ˆ์ƒ๊ณผ ๋‹ค๋ฅธ API ์‘๋‹ต: {result}")
223
+ table_html = "<p>๊ฒ€์ƒ‰ ๊ฒฐ๊ณผ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.</p>"
224
+ cat_choices = ["์ „์ฒด ๋ณด๊ธฐ"]
225
+ vol_choices = ["์ „์ฒด"]
226
+ selected_cat = "์ „์ฒด ๋ณด๊ธฐ"
227
+ download_file = None
228
 
229
  local_file = None
230
  if download_file:
 
269
  api_name="/process_analyze_results"
270
  )
271
 
272
+ # API ์‘๋‹ต ํ™•์ธ ๋ฐ ์ฒ˜๋ฆฌ
273
+ logger.info(f"๋ถ„์„ API ์‘๋‹ต ํƒ€์ž…: {type(result)}, ๊ธธ์ด: {len(result) if isinstance(result, (list, tuple)) else 'N/A'}")
274
+
275
+ if isinstance(result, (list, tuple)) and len(result) >= 2:
276
+ analysis_result, download_file = result[:2]
277
+ elif isinstance(result, str):
278
+ analysis_result = result
279
+ download_file = None
280
+ else:
281
+ logger.warning(f"์˜ˆ์ƒ๊ณผ ๋‹ค๋ฅธ ๋ถ„์„ API ์‘๋‹ต: {result}")
282
+ analysis_result = "๋ถ„์„ ๊ฒฐ๊ณผ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค."
283
+ download_file = None
284
 
285
  local_file = None
286
  if download_file: