neuralworm commited on
Commit
8902f5e
·
1 Parent(s): a43193c

better json output

Browse files
Files changed (1) hide show
  1. app.py +2 -23
app.py CHANGED
@@ -331,20 +331,7 @@ with gr.Blocks() as app:
331
  # --- Output Components ---
332
  markdown_output = gr.Dataframe(label="ELS Results")
333
  most_frequent_phrase_output = gr.Textbox(label="Most Frequent Phrase in Network Search")
334
- json_output = gr.Textbox(label="JSON Output")
335
- copy_json_button = gr.Button("Copy JSON to Clipboard")
336
-
337
- # --- Hidden HTML component to hold the JavaScript function ---
338
- html_js = gr.HTML(
339
- """
340
- <script>
341
- function copyJSON(json_string) {
342
- navigator.clipboard.writeText(json_string);
343
- }
344
- </script>
345
- """, visible=False # Hide the HTML component
346
- )
347
-
348
 
349
  # --- Event Handlers ---
350
 
@@ -524,7 +511,7 @@ with gr.Blocks() as app:
524
  "results": combined_and_sorted_results # Use the combined list here
525
  }
526
 
527
- json_data = json.dumps(output_data, ensure_ascii=False, indent=4)
528
 
529
  # --- Return results ---
530
  combined_most_frequent = "\n".join(
@@ -558,14 +545,6 @@ with gr.Blocks() as app:
558
  outputs=[date_words_output]
559
  )
560
 
561
- copy_json_button.click(
562
- js="""
563
- (json_string) => {
564
- copyJSON(json_string); // Call the JavaScript function defined in the HTML component
565
- }""",
566
- inputs=json_output, # Make sure json_output is an input
567
- )
568
-
569
  use_day.change(
570
  update_date_words,
571
  inputs=[selected_date, date_language_input, use_day, use_month, use_year],
 
331
  # --- Output Components ---
332
  markdown_output = gr.Dataframe(label="ELS Results")
333
  most_frequent_phrase_output = gr.Textbox(label="Most Frequent Phrase in Network Search")
334
+ json_output = gr.JSON(label="JSON Output")
 
 
 
 
 
 
 
 
 
 
 
 
 
335
 
336
  # --- Event Handlers ---
337
 
 
511
  "results": combined_and_sorted_results # Use the combined list here
512
  }
513
 
514
+ json_data = output_data
515
 
516
  # --- Return results ---
517
  combined_most_frequent = "\n".join(
 
545
  outputs=[date_words_output]
546
  )
547
 
 
 
 
 
 
 
 
 
548
  use_day.change(
549
  update_date_words,
550
  inputs=[selected_date, date_language_input, use_day, use_month, use_year],