macgaga commited on
Commit
90df534
·
verified ·
1 Parent(s): 67f02a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -22
app.py CHANGED
@@ -61,6 +61,18 @@ last_cn_on = False
61
 
62
  MAX_SEED = 2**32-1
63
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  with gr.Blocks() as app:
65
  # Debug-Log-Feld hinzufügen
66
  debug_log = gr.Textbox(
@@ -79,28 +91,28 @@ with gr.Blocks() as app:
79
  )
80
  test_button = gr.Button("Run Test")
81
 
82
- # Funktion zum Testen
83
- def run_test(input_text, debug_log):
84
- try:
85
- # Eingabe auf bekannte Tests prüfen
86
- if input_text == "get_custom_image":
87
- result = get_custom_image()
88
- else:
89
- result = f"Unbekannter Test: {input_text}"
90
- # Ergebnis ins Debug-Log schreiben
91
- updated_log = debug_log + f"\nTest '{input_text}': {result}"
92
- return updated_log
93
- except Exception as e:
94
- # Fehler ebenfalls ins Debug-Log schreiben
95
- updated_log = debug_log + f"\nFehler beim Test '{input_text}': {str(e)}"
96
- return updated_log
97
-
98
- # Test-Button mit der Funktion verbinden
99
- test_button.click(
100
- run_test,
101
- inputs=[test_input, debug_log],
102
- outputs=debug_log
103
- )
104
 
105
 
106
  # Hilfsfunktion zum Anhängen von Logs
 
61
 
62
  MAX_SEED = 2**32-1
63
 
64
+ with gr.Blocks() as demo:
65
+ input_box = gr.Textbox(label="Input")
66
+ output_box = gr.Textbox(label="Output")
67
+ test_button = gr.Button("Test")
68
+
69
+ def dummy_function(text):
70
+ return f"Echo: {text}"
71
+
72
+ test_button.click(dummy_function, inputs=[input_box], outputs=[output_box])
73
+
74
+ demo.launch()
75
+
76
  with gr.Blocks() as app:
77
  # Debug-Log-Feld hinzufügen
78
  debug_log = gr.Textbox(
 
91
  )
92
  test_button = gr.Button("Run Test")
93
 
94
+ # Funktion zum Testen
95
+ def run_test(input_text, debug_log):
96
+ try:
97
+ # Eingabe auf bekannte Tests prüfen
98
+ if input_text == "get_custom_image":
99
+ result = get_custom_image()
100
+ else:
101
+ result = f"Unbekannter Test: {input_text}"
102
+ # Ergebnis ins Debug-Log schreiben
103
+ updated_log = debug_log + f"\nTest '{input_text}': {result}"
104
+ return updated_log
105
+ except Exception as e:
106
+ # Fehler ebenfalls ins Debug-Log schreiben
107
+ updated_log = debug_log + f"\nFehler beim Test '{input_text}': {str(e)}"
108
+ return updated_log
109
+
110
+ # Test-Button mit der Funktion verbinden
111
+ test_button.click(
112
+ run_test,
113
+ inputs=[test_input, debug_log],
114
+ outputs=debug_log
115
+ )
116
 
117
 
118
  # Hilfsfunktion zum Anhängen von Logs