ginipick commited on
Commit
9ede46a
·
verified ·
1 Parent(s): c5ce4c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -145,6 +145,7 @@ def analyze_space(url: str, progress=gr.Progress()):
145
  print(traceback.format_exc())
146
  return f"오류가 발생했습니다: {str(e)}", "", "", "", "", None, ""
147
 
 
148
  def create_ui():
149
  try:
150
  css = """
@@ -165,6 +166,18 @@ def create_ui():
165
  }
166
  """
167
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
169
  gr.Markdown("# HuggingFace Space Analyzer")
170
 
@@ -246,6 +259,9 @@ def create_ui():
246
  outputs=[code_tabs, code_tabs]
247
  )
248
 
 
 
 
249
  return demo
250
 
251
  except Exception as e:
@@ -257,17 +273,7 @@ if __name__ == "__main__":
257
  try:
258
  demo = create_ui()
259
  demo.queue()
260
- demo.launch(js="""
261
- function openFile(path, spaceId) {
262
- const filePathInput = document.querySelector('input[data-testid="file_path_input"]');
263
- const spaceIdInput = document.querySelector('input[data-testid="space_id_input"]');
264
- if (filePathInput && spaceIdInput) {
265
- filePathInput.value = path;
266
- spaceIdInput.value = spaceId;
267
- filePathInput.dispatchEvent(new Event('change'));
268
- }
269
- }
270
- """)
271
  except Exception as e:
272
  print(f"Error in main: {str(e)}")
273
  print(traceback.format_exc())
 
145
  print(traceback.format_exc())
146
  return f"오류가 발생했습니다: {str(e)}", "", "", "", "", None, ""
147
 
148
+
149
  def create_ui():
150
  try:
151
  css = """
 
166
  }
167
  """
168
 
169
+ js = """
170
+ function openFile(path, spaceId) {
171
+ const filePathInput = document.querySelector('input[data-testid="file_path_input"]');
172
+ const spaceIdInput = document.querySelector('input[data-testid="space_id_input"]');
173
+ if (filePathInput && spaceIdInput) {
174
+ filePathInput.value = path;
175
+ spaceIdInput.value = spaceId;
176
+ filePathInput.dispatchEvent(new Event('change'));
177
+ }
178
+ }
179
+ """
180
+
181
  with gr.Blocks(css=css, theme="Nymbo/Nymbo_Theme") as demo:
182
  gr.Markdown("# HuggingFace Space Analyzer")
183
 
 
259
  outputs=[code_tabs, code_tabs]
260
  )
261
 
262
+ # JavaScript 코드를 HTML에 직접 삽입
263
+ gr.HTML(f"<script>{js}</script>")
264
+
265
  return demo
266
 
267
  except Exception as e:
 
273
  try:
274
  demo = create_ui()
275
  demo.queue()
276
+ demo.launch()
 
 
 
 
 
 
 
 
 
 
277
  except Exception as e:
278
  print(f"Error in main: {str(e)}")
279
  print(traceback.format_exc())