maryna7679 commited on
Commit
96196b4
·
1 Parent(s): 148fdbe

Login test again

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -11,7 +11,10 @@ user = "anonymous_user"
11
 
12
  def get_username(profile: gr.OAuthProfile):
13
  global user
14
- user = profile.username
 
 
 
15
  return profile
16
 
17
 
@@ -46,6 +49,7 @@ def show_add_entry_form():
46
 
47
  def save_entry(df, start_time, text, end_time, selected_row_idx, video_id):
48
  """Save or update a caption entry"""
 
49
  if user == "anonymous_user":
50
  return df, gr.update(visible=True), gr.Warning("Please sign in to save changes")
51
  try:
@@ -119,11 +123,11 @@ with gr.Blocks(css=css, head=yt_init_js) as main_page:
119
 
120
  gr.LoginButton()
121
 
122
- current_user = gr.Textbox(visible=False, interactive=False)
123
  current_video_id = gr.Textbox(value=start_video_id, visible=False, interactive=False)
124
  selected_row_idx = gr.Number(value=-1, visible=False)
125
 
126
- main_page.load(get_username, outputs=current_user) # Disabled when auth is disabled
127
 
128
  # Load initial video on page load
129
  main_page.load(
 
11
 
12
  def get_username(profile: gr.OAuthProfile):
13
  global user
14
+ if profile is None:
15
+ user = "anonymous_user"
16
+ else:
17
+ user = profile.username
18
  return profile
19
 
20
 
 
49
 
50
  def save_entry(df, start_time, text, end_time, selected_row_idx, video_id):
51
  """Save or update a caption entry"""
52
+ main_page.load(get_username)
53
  if user == "anonymous_user":
54
  return df, gr.update(visible=True), gr.Warning("Please sign in to save changes")
55
  try:
 
123
 
124
  gr.LoginButton()
125
 
126
+ # current_user = gr.Textbox(visible=False, interactive=False)
127
  current_video_id = gr.Textbox(value=start_video_id, visible=False, interactive=False)
128
  selected_row_idx = gr.Number(value=-1, visible=False)
129
 
130
+ main_page.load(get_username) # Disabled when auth is disabled
131
 
132
  # Load initial video on page load
133
  main_page.load(