anferico commited on
Commit
645d1bb
1 Parent(s): 2634b02
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -7,14 +7,14 @@ def enable_second_task(secret):
7
  if secret == os.environ["SECRET_KEY"]:
8
  return [
9
  gr.Textbox.update(visible=False),
10
- gr.HTML(visible=False),
11
  gr.Button.update(visible=False),
12
  gr.Textbox.update(visible=True),
13
  gr.Textbox.update(visible=True),
14
  gr.Button.update(visible=True)
15
  ]
16
  return [
17
- gr.Textbox.update(visible=True),
18
  gr.HTML.update(visible=True),
19
  gr.Button.update(visible=True),
20
  gr.Textbox.update(visible=False),
@@ -29,7 +29,8 @@ demo = gr.Blocks()
29
  with demo:
30
  # Authentication
31
  secret_textbox = gr.Textbox(
32
- placeholder="Enter secret key", label="Secret", show_label=True
 
33
  )
34
  error_message = gr.HTML(
35
  "<span style=\"color: red;\">Wrong secret key. Please retry</span>",
@@ -46,6 +47,13 @@ with demo:
46
  )
47
  greet_button = gr.Button("Greet", visible=False)
48
 
 
 
 
 
 
 
 
49
  secret_button.click(
50
  enable_second_task,
51
  secret_textbox,
 
7
  if secret == os.environ["SECRET_KEY"]:
8
  return [
9
  gr.Textbox.update(visible=False),
10
+ gr.HTML.update(visible=False),
11
  gr.Button.update(visible=False),
12
  gr.Textbox.update(visible=True),
13
  gr.Textbox.update(visible=True),
14
  gr.Button.update(visible=True)
15
  ]
16
  return [
17
+ gr.Textbox.update(value="", visible=True),
18
  gr.HTML.update(visible=True),
19
  gr.Button.update(visible=True),
20
  gr.Textbox.update(visible=False),
 
29
  with demo:
30
  # Authentication
31
  secret_textbox = gr.Textbox(
32
+ placeholder="Enter secret key", label="Secret", show_label=True,
33
+ max_lines=1
34
  )
35
  error_message = gr.HTML(
36
  "<span style=\"color: red;\">Wrong secret key. Please retry</span>",
 
47
  )
48
  greet_button = gr.Button("Greet", visible=False)
49
 
50
+ # Event handling
51
+ secret_textbox.submit(
52
+ enable_second_task,
53
+ secret_textbox,
54
+ [secret_textbox, error_message, secret_button,
55
+ name_textbox, greet_textbox, greet_button]
56
+ )
57
  secret_button.click(
58
  enable_second_task,
59
  secret_textbox,