Chris Addis commited on
Commit
163b56c
·
1 Parent(s): b993ed1

fix additional models

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -39,7 +39,8 @@ def get_user_access_level(request: gr.Request):
39
 
40
  print(f"Logged in user: Username={username}, ID={user_id}") # Log for debugging
41
 
42
- if user_id in AUTHORIZED_USER_IDS and user_id != "": # Also check if user_id is not empty string from split(",")
 
43
  # User is authorized for full access
44
  print(f"User {user_id} is authorized for full access.")
45
  return {
@@ -79,7 +80,6 @@ with gr.Blocks() as demo:
79
  with gr.Column(visible=True) as limited_content_column:
80
  gr.Markdown("## Limited Access Content")
81
  gr.Textbox(value="This is content visible to everyone or users with limited access.", interactive=False)
82
- gr.Image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/welcome/hugging-face-logo.png", width=200)
83
  gr.Markdown("*(Sign in and/or get authorized for more features!)*")
84
  # Add other limited features here
85
 
@@ -87,7 +87,6 @@ with gr.Blocks() as demo:
87
  with gr.Column(visible=False) as full_content_column:
88
  gr.Markdown("## Full Access Content")
89
  gr.Textbox(value="🥳 Congratulations! You have unlocked the full version! 🥳", interactive=False)
90
- gr.Video("https://huggingface.co/spaces/gradio/space-tourism/resolve/main/space-tourism.mp4")
91
  gr.Markdown("*(This content is only for authorized accounts)*")
92
  # Add other full features here
93
 
@@ -111,9 +110,8 @@ with gr.Blocks() as demo:
111
  ]
112
  )
113
 
114
- # Initial check when the page loads (might need a small delay or specific trigger depending on HF/Gradio loading)
115
- # A common pattern is to call a load function or rely on the button click after redirect.
116
- # Let's add a load event to trigger the check immediately on page load attempt.
117
  demo.load(
118
  fn=get_user_access_level,
119
  inputs=None,
@@ -126,5 +124,8 @@ with gr.Blocks() as demo:
126
  ]
127
  )
128
 
129
-
 
 
 
130
  demo.launch()
 
39
 
40
  print(f"Logged in user: Username={username}, ID={user_id}") # Log for debugging
41
 
42
+ # Check if user_id is in the authorized set and is not just an empty string from split("")
43
+ if user_id in AUTHORIZED_USER_IDS and user_id != "":
44
  # User is authorized for full access
45
  print(f"User {user_id} is authorized for full access.")
46
  return {
 
80
  with gr.Column(visible=True) as limited_content_column:
81
  gr.Markdown("## Limited Access Content")
82
  gr.Textbox(value="This is content visible to everyone or users with limited access.", interactive=False)
 
83
  gr.Markdown("*(Sign in and/or get authorized for more features!)*")
84
  # Add other limited features here
85
 
 
87
  with gr.Column(visible=False) as full_content_column:
88
  gr.Markdown("## Full Access Content")
89
  gr.Textbox(value="🥳 Congratulations! You have unlocked the full version! 🥳", interactive=False)
 
90
  gr.Markdown("*(This content is only for authorized accounts)*")
91
  # Add other full features here
92
 
 
110
  ]
111
  )
112
 
113
+ # Initial check when the page loads. This helps set the initial state
114
+ # based on whether the user is already logged in from a previous session/redirect.
 
115
  demo.load(
116
  fn=get_user_access_level,
117
  inputs=None,
 
124
  ]
125
  )
126
 
127
+ # --- Launch the App ---
128
+ # For local testing, hf_oauth won't work, request.auth will be None.
129
+ # The app will show the login prompt and limited content.
130
+ # For deployment on HF Spaces, configure README.md and Secrets.
131
  demo.launch()