curiousgeorge1292 commited on
Commit
977c309
·
verified ·
1 Parent(s): 943f3ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -30,8 +30,7 @@ with open("temp_client_secrets.json", "w") as temp_file:
30
  json.dump(client_secrets, temp_file)
31
 
32
  # Initialize Flow using the temporary JSON file
33
- try:
34
- flow = Flow.from_client_secrets_file(
35
  'temp_client_secrets.json', # Path to the temporary JSON file
36
  scopes=['https://www.googleapis.com/auth/gmail.compose'],
37
  redirect_uri="https://huggingface.co/spaces/curiousgeorge1292/Custom_Profile_Email_Generator/oauth2callback"
@@ -83,10 +82,8 @@ def save_to_gmail_drafts(subject, body, recipient):
83
  return f"Draft created with ID: {draft['id']}"
84
 
85
  # Clean up the temporary file
86
- finally:
87
- # Always delete the temporary file
88
- if os.path.exists("temp_client_secrets.json"):
89
- os.remove("temp_client_secrets.json")
90
 
91
  # Initialize Groq client
92
  client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
 
30
  json.dump(client_secrets, temp_file)
31
 
32
  # Initialize Flow using the temporary JSON file
33
+ flow = Flow.from_client_secrets_file(
 
34
  'temp_client_secrets.json', # Path to the temporary JSON file
35
  scopes=['https://www.googleapis.com/auth/gmail.compose'],
36
  redirect_uri="https://huggingface.co/spaces/curiousgeorge1292/Custom_Profile_Email_Generator/oauth2callback"
 
82
  return f"Draft created with ID: {draft['id']}"
83
 
84
  # Clean up the temporary file
85
+ if os.path.exists("temp_client_secrets.json"):
86
+ os.remove("temp_client_secrets.json")
 
 
87
 
88
  # Initialize Groq client
89
  client = Groq(api_key=os.environ.get("GROQ_API_KEY"))