wuhp commited on
Commit
199a115
·
verified ·
1 Parent(s): 2a3b5a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -60,9 +60,9 @@ class ReportSender:
60
 
61
  log_history = f" Starting batch loop for {num_urls} report types...\n"
62
  if csrf_token:
63
- log_history += " CSRF Token detected and applied.\n"
64
  else:
65
- log_history += " WARNING: Could not find 'tt_csrf_token'.\n"
66
 
67
  yield log_history, self.is_running, "Running"
68
  total_requests_sent = 0
@@ -112,9 +112,9 @@ class ReportSender:
112
  else:
113
  status_icon = "FAIL"
114
  if not is_empty_success and not is_json_success:
115
- status_msg = f"Failed ({response.status_code}): Code: {status_code_val} | Msg: {status_code_msg}"
116
  else:
117
- status_msg = f"Failed ({response.status_code}): Unexpected Error"
118
 
119
  log_entry = (
120
  f"[{timestamp}] {status_icon} REQ ({total_requests_sent}): {report_name}\n"
@@ -156,14 +156,12 @@ with gr.Blocks() as app:
156
  gr.Markdown("### 1. Request Context")
157
  cookie_input = gr.Textbox(
158
  label="Full Browser Cookie Header",
159
- placeholder="Paste Cookie string here",
160
  lines=5, max_lines=5
161
  )
162
 
163
  gr.Markdown("### 2. Report URLs Batch")
164
  master_url_batch_input = gr.Textbox(
165
  label="Master Signed Report URLs",
166
- placeholder="Paste URLs here",
167
  lines=5, max_lines=10
168
  )
169
 
@@ -183,37 +181,38 @@ with gr.Blocks() as app:
183
  gr.Markdown("### 4. Execution Logs")
184
  logs_output = gr.Textbox(
185
  show_label=False,
186
- placeholder="Logs will appear here...",
187
  lines=20, max_lines=20,
188
  autoscroll=True,
189
  elem_id="log-box"
190
  )
191
 
 
 
 
 
 
 
192
  run_event = send_btn.click(
193
  fn=sender.execute_reports_loop,
194
  inputs=[master_url_batch_input, cookie_input, batch_count_input, current_status],
195
  outputs=[logs_output, is_running_state, status_box],
196
  )
197
 
198
- send_btn.click(
199
- fn=lambda: [gr.Button(interactive=False), gr.Button(interactive=True)],
200
- outputs=[send_btn, stop_btn]
201
- )
202
-
203
  run_event.then(
204
- fn=lambda: [gr.Button(interactive=True), gr.Button(interactive=False), "Stopped"],
205
- outputs=[send_btn, stop_btn, status_box]
206
  )
207
 
208
  stop_btn.click(
209
  fn=sender.stop_execution,
210
- inputs=[],
211
- outputs=[],
212
  cancels=[run_event],
213
  queue=False
214
  ).then(
215
- fn=lambda: [gr.Button(interactive=True), gr.Button(interactive=False), "Stopped"],
216
- outputs=[send_btn, stop_btn, status_box]
 
217
  )
218
 
219
  status_box.change(lambda x: x, inputs=status_box, outputs=current_status)
 
60
 
61
  log_history = f" Starting batch loop for {num_urls} report types...\n"
62
  if csrf_token:
63
+ log_history += " CSRF Token applied.\n"
64
  else:
65
+ log_history += " WARNING: No 'tt_csrf_token' found.\n"
66
 
67
  yield log_history, self.is_running, "Running"
68
  total_requests_sent = 0
 
112
  else:
113
  status_icon = "FAIL"
114
  if not is_empty_success and not is_json_success:
115
+ status_msg = f"Failed ({response.status_code}): {status_code_msg}"
116
  else:
117
+ status_msg = f"Failed ({response.status_code})"
118
 
119
  log_entry = (
120
  f"[{timestamp}] {status_icon} REQ ({total_requests_sent}): {report_name}\n"
 
156
  gr.Markdown("### 1. Request Context")
157
  cookie_input = gr.Textbox(
158
  label="Full Browser Cookie Header",
 
159
  lines=5, max_lines=5
160
  )
161
 
162
  gr.Markdown("### 2. Report URLs Batch")
163
  master_url_batch_input = gr.Textbox(
164
  label="Master Signed Report URLs",
 
165
  lines=5, max_lines=10
166
  )
167
 
 
181
  gr.Markdown("### 4. Execution Logs")
182
  logs_output = gr.Textbox(
183
  show_label=False,
 
184
  lines=20, max_lines=20,
185
  autoscroll=True,
186
  elem_id="log-box"
187
  )
188
 
189
+ send_btn.click(
190
+ fn=lambda: (gr.update(interactive=False), gr.update(interactive=True)),
191
+ outputs=[send_btn, stop_btn],
192
+ queue=False
193
+ )
194
+
195
  run_event = send_btn.click(
196
  fn=sender.execute_reports_loop,
197
  inputs=[master_url_batch_input, cookie_input, batch_count_input, current_status],
198
  outputs=[logs_output, is_running_state, status_box],
199
  )
200
 
 
 
 
 
 
201
  run_event.then(
202
+ fn=lambda: (gr.update(interactive=True), gr.update(interactive=False)),
203
+ outputs=[send_btn, stop_btn]
204
  )
205
 
206
  stop_btn.click(
207
  fn=sender.stop_execution,
208
+ inputs=None,
209
+ outputs=None,
210
  cancels=[run_event],
211
  queue=False
212
  ).then(
213
+ fn=lambda: (gr.update(interactive=True), gr.update(interactive=False), "Stopped"),
214
+ outputs=[send_btn, stop_btn, status_box],
215
+ queue=False
216
  )
217
 
218
  status_box.change(lambda x: x, inputs=status_box, outputs=current_status)