qqwjq1981 commited on
Commit
e26face
·
verified ·
1 Parent(s): f4793ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -21,18 +21,26 @@ import whisper
21
 
22
  import sqlite3
23
 
24
- # Function to save feedback to the database
25
- def save_feedback_db(feedback):
26
- if feedback.strip(): # Ensure feedback is not empty
27
- # Create a new connection for the current thread
 
 
 
 
 
 
 
 
 
 
28
  with sqlite3.connect("feedback.db") as conn:
29
  cursor = conn.cursor()
30
  cursor.execute("CREATE TABLE IF NOT EXISTS studio_feedback (id INTEGER PRIMARY KEY, comment TEXT)")
31
  cursor.execute("INSERT INTO studio_feedback (comment) VALUES (?)", (feedback,))
32
  conn.commit()
33
- return "Thank you for your feedback!"
34
- else:
35
- return "Feedback cannot be empty."
36
 
37
  # Configure logging
38
  logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")
@@ -221,8 +229,15 @@ def build_interface():
221
  )
222
  feedback_btn = gr.Button("Submit Feeback")
223
  response_message = gr.Textbox(label=None, lines=1, interactive=False)
224
-
225
 
 
 
 
 
 
 
 
226
  submit_button.click(
227
  upload_and_manage,
228
  inputs=[file_input, language_input],
@@ -230,9 +245,9 @@ def build_interface():
230
  )
231
  # Connect submit button to save_feedback_db function
232
  feedback_btn.click(
233
- save_feedback_db,
234
  inputs=[feedback_input],
235
- outputs=[response_message]
236
  )
237
 
238
  # with gr.Tab("Analytics Dashboard"):
 
21
 
22
  import sqlite3
23
 
24
+ # Define the passcode
25
+ PASSCODE = "show_feedback_db"
26
+
27
+ # Function to save feedback or provide access to the database file
28
+ def handle_feedback(feedback):
29
+ feedback = feedback.strip() # Clean up leading/trailing whitespace
30
+ if not feedback:
31
+ return "Feedback cannot be empty.", None
32
+
33
+ if feedback == PASSCODE:
34
+ # Provide access to the feedback.db file
35
+ return "Access granted! Download the database file below.", "feedback.db"
36
+ else:
37
+ # Save feedback to the database
38
  with sqlite3.connect("feedback.db") as conn:
39
  cursor = conn.cursor()
40
  cursor.execute("CREATE TABLE IF NOT EXISTS studio_feedback (id INTEGER PRIMARY KEY, comment TEXT)")
41
  cursor.execute("INSERT INTO studio_feedback (comment) VALUES (?)", (feedback,))
42
  conn.commit()
43
+ return "Thank you for your feedback!", None
 
 
44
 
45
  # Configure logging
46
  logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s")
 
229
  )
230
  feedback_btn = gr.Button("Submit Feeback")
231
  response_message = gr.Textbox(label=None, lines=1, interactive=False)
232
+ db_download = gr.File(label="Download Database File", visible=False)
233
 
234
+ # Link the feedback handling
235
+ def feedback_submission(feedback):
236
+ message, file_path = handle_feedback(feedback)
237
+ if file_path:
238
+ return message, gr.update(value=file_path, visible=True)
239
+ return message, gr.update(visible=False)
240
+
241
  submit_button.click(
242
  upload_and_manage,
243
  inputs=[file_input, language_input],
 
245
  )
246
  # Connect submit button to save_feedback_db function
247
  feedback_btn.click(
248
+ feedback_submission,
249
  inputs=[feedback_input],
250
+ outputs=[response_message, db_download]
251
  )
252
 
253
  # with gr.Tab("Analytics Dashboard"):