Spaces:
Runtime error
Runtime error
import gradio as gr | |
import gspread | |
from oauth2client.service_account import ServiceAccountCredentials | |
# Use creds to create a client to interact with the Google Drive API | |
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"] | |
creds = ServiceAccountCredentials.from_json_keyfile_name('service_account.json', scope) | |
client = gspread.authorize(creds) | |
# Find a workbook by name and open the specific sheet | |
spreadsheet = client.open("Food or Drink Order") | |
sheet = spreadsheet.worksheet('Gradio') | |
def write_to_sheet(name, email): | |
row = [name, email] | |
sheet.append_row(row) | |
return f"Data {name} and {email} has been written to the sheet." | |
iface = gr.Interface(fn=write_to_sheet, | |
inputs=["text", "text"], | |
outputs="text", | |
interpretation="default") | |
iface.launch(share=True) |