Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -32,20 +32,25 @@ def compute_final_suggested_location(rows):
|
|
32 |
return counts, (top_location, count)
|
33 |
|
34 |
# Store feedback (with required fields)
|
35 |
-
|
|
|
|
|
|
|
36 |
if not answer1.strip() or not answer2.strip():
|
37 |
return "⚠️ Please answer both questions before submitting."
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
#
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
|
50 |
def summarize_results(accession):
|
51 |
try:
|
@@ -128,7 +133,7 @@ with gr.Blocks() as interface:
|
|
128 |
|
129 |
run_button.click(fn=classify_with_loading, inputs=accession, outputs=status)
|
130 |
run_button.click(fn=classify_main, inputs=accession, outputs=[output_table, output_summary, status])
|
131 |
-
submit_feedback.click(fn=
|
132 |
reset_button.click(fn=reset_fields, inputs=[], outputs=[accession, q1, q2, contact, feedback_status, output_table, output_summary, status])
|
133 |
|
134 |
interface.launch(share=True)
|
|
|
32 |
return counts, (top_location, count)
|
33 |
|
34 |
# Store feedback (with required fields)
|
35 |
+
import gspread
|
36 |
+
from oauth2client.service_account import ServiceAccountCredentials
|
37 |
+
|
38 |
+
def store_feedback_to_google_sheets(accession, answer1, answer2, contact=""):
|
39 |
if not answer1.strip() or not answer2.strip():
|
40 |
return "⚠️ Please answer both questions before submitting."
|
41 |
|
42 |
+
try:
|
43 |
+
# Define the scope and authenticate
|
44 |
+
scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/drive"]
|
45 |
+
creds = ServiceAccountCredentials.from_json_keyfile_name("credentials.json", scope)
|
46 |
+
client = gspread.authorize(creds)
|
47 |
+
|
48 |
+
# Open the spreadsheet and worksheet
|
49 |
+
sheet = client.open("feedback_mtdna").sheet1 # You can change the name
|
50 |
+
sheet.append_row([accession, answer1, answer2, contact])
|
51 |
+
return "✅ Feedback submitted. Thank you!"
|
52 |
+
except Exception as e:
|
53 |
+
return f"❌ Error submitting feedback: {str(e)}"
|
54 |
|
55 |
def summarize_results(accession):
|
56 |
try:
|
|
|
133 |
|
134 |
run_button.click(fn=classify_with_loading, inputs=accession, outputs=status)
|
135 |
run_button.click(fn=classify_main, inputs=accession, outputs=[output_table, output_summary, status])
|
136 |
+
submit_feedback.click(fn=store_feedback_to_google_sheets, inputs=[accession, q1, q2, contact], outputs=feedback_status)
|
137 |
reset_button.click(fn=reset_fields, inputs=[], outputs=[accession, q1, q2, contact, feedback_status, output_table, output_summary, status])
|
138 |
|
139 |
interface.launch(share=True)
|