faizee07 commited on
Commit
9fd1ca7
·
verified ·
1 Parent(s): 98db39e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -73,15 +73,24 @@ def create_meme(idea: str, template: str):
73
  if not idea or len(idea.strip()) < 3:
74
  return None, "❌ Please enter a meme idea (at least 3 characters)!"
75
 
 
 
 
 
 
 
 
76
  top, bottom, error, model_used = generate_meme_text(idea)
77
  if error: return None, error
78
 
79
  template_id = MEME_TEMPLATES.get(template, "181913649")
80
  url = "https://api.imgflip.com/caption_image"
81
 
82
- # --- FINAL FIX: Removed username and password from the payload ---
83
  payload = {
84
  'template_id': template_id,
 
 
85
  'text0': top,
86
  'text1': bottom
87
  }
@@ -114,6 +123,7 @@ def create_meme(idea: str, template: str):
114
  return None, f"❌ **An unexpected error occurred:** {str(e)}"
115
 
116
  # --- CONFIGURATION & UI (No changes needed) ---
 
117
 
118
  MEME_TEMPLATES = {
119
  "Drake": "181913649", "Distracted Boyfriend": "112126428", "Two Buttons": "87743020",
 
73
  if not idea or len(idea.strip()) < 3:
74
  return None, "❌ Please enter a meme idea (at least 3 characters)!"
75
 
76
+ # --- FINAL FIX: Check for ImgFlip credentials ---
77
+ imgflip_user = os.environ.get("IMGFLIP_USERNAME")
78
+ imgflip_pass = os.environ.get("IMGFLIP_PASSWORD")
79
+
80
+ if not imgflip_user or not imgflip_pass:
81
+ return None, "❌ **ImgFlip Credentials Required**\n\n**Setup:**\n1. Create a free account at Imgflip.com\n2. Go to Space Settings → Repository Secrets\n3. Add `IMGFLIP_USERNAME` and `IMGFLIP_PASSWORD` secrets\n4. Restart Space."
82
+
83
  top, bottom, error, model_used = generate_meme_text(idea)
84
  if error: return None, error
85
 
86
  template_id = MEME_TEMPLATES.get(template, "181913649")
87
  url = "https://api.imgflip.com/caption_image"
88
 
89
+ # --- FINAL FIX: Use your credentials from the secrets ---
90
  payload = {
91
  'template_id': template_id,
92
+ 'username': imgflip_user,
93
+ 'password': imgflip_pass,
94
  'text0': top,
95
  'text1': bottom
96
  }
 
123
  return None, f"❌ **An unexpected error occurred:** {str(e)}"
124
 
125
  # --- CONFIGURATION & UI (No changes needed) ---
126
+ # [UI code remains the same]
127
 
128
  MEME_TEMPLATES = {
129
  "Drake": "181913649", "Distracted Boyfriend": "112126428", "Two Buttons": "87743020",