Bryceeee commited on
Commit
439677e
·
verified ·
1 Parent(s): d06a005

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -226,22 +226,15 @@ def create_app():
226
  demo = interface_builder.create_interface()
227
 
228
  # Set authentication for Hugging Face Spaces
229
- # In Gradio 6.0+, we can set auth after creating the demo
 
230
  if auth_username and auth_password:
231
  auth_config = (auth_username, auth_password)
232
- try:
233
- # Method 1: Try setting auth attribute directly (Gradio 6.0+)
234
- if hasattr(demo, 'auth'):
235
- demo.auth = auth_config
236
- print("✅ Authentication configured via demo.auth")
237
- else:
238
- # Method 2: Store auth config for Spaces to use
239
- demo._auth = auth_config
240
- print("✅ Authentication configured (stored for launch)")
241
- except Exception as e:
242
- print(f"⚠️ Error setting auth: {e}")
243
- # Fallback: store in custom attribute
244
- demo._auth_config = auth_config
245
 
246
  return demo
247
 
 
226
  demo = interface_builder.create_interface()
227
 
228
  # Set authentication for Hugging Face Spaces
229
+ # Note: In Gradio 6.0 on Spaces, auth should be set via launch() parameters
230
+ # Since Spaces auto-launches, we'll store auth config for potential use
231
  if auth_username and auth_password:
232
  auth_config = (auth_username, auth_password)
233
+ # Store auth config - Spaces may use this when auto-launching
234
+ # For Gradio 6.0, we can't directly set demo.auth before launch
235
+ # Spaces will handle authentication if configured properly
236
+ demo._hf_auth = auth_config
237
+ print("✅ Authentication credentials stored (Spaces will handle on launch)")
 
 
 
 
 
 
 
 
238
 
239
  return demo
240