akhaliq HF Staff commited on
Commit
efee1d5
·
verified ·
1 Parent(s): fea8f7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
app.py CHANGED
@@ -76,28 +76,25 @@ def generate_video(
76
 
77
  def generate_with_pro_auth(
78
  prompt: str,
79
- manual_token: str,
80
  oauth_token: Optional[gr.OAuthToken] = None
81
  ) -> Tuple[Optional[str], str]:
82
  """
83
  Wrapper function that checks if user is PRO before generating video.
84
  """
85
- # Check if user is PRO (either through OAuth or manual token)
86
- if not (verify_pro_status(oauth_token) or verify_pro_status(manual_token)):
87
  raise gr.Error("Access Denied. This app is exclusively for Hugging Face PRO users. Please subscribe to PRO to use this app.")
88
 
89
  if not prompt or prompt.strip() == "":
90
  return None, "❌ Please enter a prompt"
91
 
92
- # Use the oauth token if available, otherwise manual token
93
- token_to_use = oauth_token.token if oauth_token else manual_token
94
-
95
- # Generate video with the PRO user's token
96
  video_path, status = generate_video(
97
  prompt,
98
  duration=8,
99
  size="1280x720",
100
- api_key=token_to_use
101
  )
102
 
103
  return video_path, status
@@ -190,13 +187,7 @@ def create_ui():
190
  visible=True
191
  )
192
 
193
- # Hidden manual token input (for API usage)
194
- manual_token = gr.Textbox(
195
- label="Manual Token (for API usage)",
196
- placeholder="Paste your HF token here if using the API",
197
- type="password",
198
- visible=False
199
- )
200
 
201
  # Examples section with queue disabled
202
  gr.Examples(
@@ -219,7 +210,7 @@ def create_ui():
219
  # Event handler for generation with queue disabled
220
  generate_btn.click(
221
  fn=generate_with_pro_auth,
222
- inputs=[prompt_input, manual_token],
223
  outputs=[video_output, status_output],
224
  queue=False,
225
  api_name=False,
@@ -230,7 +221,6 @@ def create_ui():
230
  gr.HTML("""
231
  <div style="text-align: center; margin-top: 40px; padding: 20px; border-top: 1px solid #e0e0e0;">
232
  <h3 style="color: #667eea;">Thank you for being a PRO user! 🤗</h3>
233
- <p>Built with ❤️ using <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">anycoder</a></p>
234
  </div>
235
  """)
236
 
 
76
 
77
  def generate_with_pro_auth(
78
  prompt: str,
 
79
  oauth_token: Optional[gr.OAuthToken] = None
80
  ) -> Tuple[Optional[str], str]:
81
  """
82
  Wrapper function that checks if user is PRO before generating video.
83
  """
84
+ # Check if user is PRO
85
+ if not verify_pro_status(oauth_token):
86
  raise gr.Error("Access Denied. This app is exclusively for Hugging Face PRO users. Please subscribe to PRO to use this app.")
87
 
88
  if not prompt or prompt.strip() == "":
89
  return None, "❌ Please enter a prompt"
90
 
91
+ # Use the environment token for API calls (with bill_to="huggingface")
92
+ # Don't use the user's OAuth token for the API call
 
 
93
  video_path, status = generate_video(
94
  prompt,
95
  duration=8,
96
  size="1280x720",
97
+ api_key=None # This will use the environment HF_TOKEN
98
  )
99
 
100
  return video_path, status
 
187
  visible=True
188
  )
189
 
190
+ # Hidden manual token input removed - not needed anymore
 
 
 
 
 
 
191
 
192
  # Examples section with queue disabled
193
  gr.Examples(
 
210
  # Event handler for generation with queue disabled
211
  generate_btn.click(
212
  fn=generate_with_pro_auth,
213
+ inputs=[prompt_input],
214
  outputs=[video_output, status_output],
215
  queue=False,
216
  api_name=False,
 
221
  gr.HTML("""
222
  <div style="text-align: center; margin-top: 40px; padding: 20px; border-top: 1px solid #e0e0e0;">
223
  <h3 style="color: #667eea;">Thank you for being a PRO user! 🤗</h3>
 
224
  </div>
225
  """)
226