Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
from google.colab import auth
|
4 |
import gspread
|
5 |
from google.auth import default
|
6 |
|
7 |
-
|
8 |
def feedback_response(feedback, comments):
|
9 |
response = ''
|
10 |
if feedback == 'Good Response':
|
@@ -16,21 +14,24 @@ def feedback_response(feedback, comments):
|
|
16 |
if comments:
|
17 |
comments = comments
|
18 |
|
19 |
-
#
|
20 |
-
auth.authenticate_user()
|
21 |
-
creds, _ = default()
|
22 |
-
gc = gspread.authorize(creds)
|
23 |
-
sheet_id = "18hnoTsEaGMWMael42MXubb-FzAe5jJB5RpaSolIXyb0"
|
24 |
-
worksheet_name = "Sheet1"
|
25 |
-
auth.authenticate_user()
|
26 |
creds, _ = default()
|
27 |
gc = gspread.authorize(creds)
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
sh = gc.open_by_key(sheet_id)
|
29 |
-
sh.worksheets()
|
30 |
worksheet = sh.worksheet(worksheet_name)
|
|
|
|
|
31 |
df = pd.DataFrame({'Response': [response],'Additional Comments': [comments]})
|
32 |
-
|
33 |
-
worksheet
|
|
|
|
|
34 |
return "Your feedback has been recorded. Thank you!"
|
35 |
|
36 |
# Set up the Gradio Interface
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
|
|
3 |
import gspread
|
4 |
from google.auth import default
|
5 |
|
|
|
6 |
def feedback_response(feedback, comments):
|
7 |
response = ''
|
8 |
if feedback == 'Good Response':
|
|
|
14 |
if comments:
|
15 |
comments = comments
|
16 |
|
17 |
+
# Authenticate and authorize with Google Sheets
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
creds, _ = default()
|
19 |
gc = gspread.authorize(creds)
|
20 |
+
|
21 |
+
# Specify your Google Sheets credentials, sheet_id, and worksheet_name
|
22 |
+
sheet_id = "YOUR_SHEET_ID"
|
23 |
+
worksheet_name = "YOUR_WORKSHEET_NAME"
|
24 |
+
|
25 |
+
# Open the Google Sheets document
|
26 |
sh = gc.open_by_key(sheet_id)
|
|
|
27 |
worksheet = sh.worksheet(worksheet_name)
|
28 |
+
|
29 |
+
# Create a DataFrame from the response
|
30 |
df = pd.DataFrame({'Response': [response],'Additional Comments': [comments]})
|
31 |
+
|
32 |
+
# Append the data to the worksheet
|
33 |
+
worksheet.append_table(df.values.tolist())
|
34 |
+
|
35 |
return "Your feedback has been recorded. Thank you!"
|
36 |
|
37 |
# Set up the Gradio Interface
|