openfree commited on
Commit
22a2119
ยท
verified ยท
1 Parent(s): 7c2e16a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -3
app.py CHANGED
@@ -1102,14 +1102,55 @@ def home():
1102
  categories_json = json.dumps(list(CATEGORIES.keys()))
1103
 
1104
  # ๋””๋ฒ„๊น…์„ ์œ„ํ•ด ๋กœ๊ทธ ์ถ”๊ฐ€
1105
- logger.info(f"Categories: {list(CATEGORIES.keys())}")
1106
  logger.info(f"Categories JSON: {categories_json}")
1107
 
1108
- # ํ…œํ”Œ๋ฆฟ์— ์‚ฝ์ž…ํ•  ๋•Œ ์ถ”๊ฐ€ ๋”ฐ์˜ดํ‘œ๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š๋„๋ก ์ˆ˜์ •
1109
- html_content = HTML_TEMPLATE.replace('"${categories}"', categories_json)
1110
 
1111
  return html_content
1112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1113
  # Initialize database on startup
1114
  init_db()
1115
 
 
1102
  categories_json = json.dumps(list(CATEGORIES.keys()))
1103
 
1104
  # ๋””๋ฒ„๊น…์„ ์œ„ํ•ด ๋กœ๊ทธ ์ถ”๊ฐ€
 
1105
  logger.info(f"Categories JSON: {categories_json}")
1106
 
1107
+ # HTML์—์„œ cats ๋ณ€์ˆ˜๊ฐ€ JavaScript ๋ฐฐ์—ด๋กœ ์ธ์‹๋˜๋„๋ก ์ˆ˜์ •
1108
+ html_content = HTML_TEMPLATE.replace('const cats = "${categories}";', f'const cats = {categories_json};')
1109
 
1110
  return html_content
1111
 
1112
+ @app.route('/debug')
1113
+ def debug():
1114
+ """๋””๋ฒ„๊น… ํŽ˜์ด์ง€"""
1115
+ categories_json = json.dumps(list(CATEGORIES.keys()))
1116
+ return f"""
1117
+ <!DOCTYPE html>
1118
+ <html>
1119
+ <head>
1120
+ <title>๋””๋ฒ„๊ทธ ํŽ˜์ด์ง€</title>
1121
+ </head>
1122
+ <body>
1123
+ <h1>์นดํ…Œ๊ณ ๋ฆฌ ํ…Œ์ŠคํŠธ</h1>
1124
+ <div id="result"></div>
1125
+
1126
+ <script>
1127
+ // ์นดํ…Œ๊ณ ๋ฆฌ ์ง์ ‘ ํ• ๋‹น
1128
+ const cats = {categories_json};
1129
+
1130
+ document.getElementById('result').innerHTML =
1131
+ "<p>Categories: " + JSON.stringify(cats) + "</p>" +
1132
+ "<p>Type: " + typeof cats + "</p>" +
1133
+ "<p>Array? " + Array.isArray(cats) + "</p>" +
1134
+ "<p>Length: " + cats.length + "</p>";
1135
+
1136
+ // ๊ฐ„๋‹จํ•œ ํƒญ ์ƒ์„ฑ ํ…Œ์ŠคํŠธ
1137
+ const tabsDiv = document.createElement('div');
1138
+ tabsDiv.style.display = 'flex';
1139
+ tabsDiv.style.gap = '10px';
1140
+ document.body.appendChild(tabsDiv);
1141
+
1142
+ cats.forEach(cat => {{
1143
+ const btn = document.createElement('button');
1144
+ btn.textContent = cat;
1145
+ btn.style.padding = '5px 15px';
1146
+ tabsDiv.appendChild(btn);
1147
+ }});
1148
+ </script>
1149
+ </body>
1150
+ </html>
1151
+ """
1152
+
1153
+
1154
  # Initialize database on startup
1155
  init_db()
1156