Rooni commited on
Commit
113590b
·
verified ·
1 Parent(s): 9c876a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -15,14 +15,17 @@ def get_data(password):
15
  else:
16
  raise gr.Error("Неверный пароль!")
17
 
18
- def send_data(text):
19
  """Функция для сохранения данных на диск."""
20
- global data
21
- data = text
22
- with open("data.txt", "w") as f:
23
- f.write(data)
24
- raise gr.Info("Данные успешно сохранены!")
25
- return get_data()
 
 
 
26
 
27
  css = """
28
  footer {visibility: hidden !important;}
@@ -40,6 +43,6 @@ with gr.Blocks(css=css) as demo:
40
  output_text = gr.Textbox(label="Результат:")
41
 
42
  get_button.click(get_data, inputs=password_input, outputs=output_text)
43
- send_button.click(send_data, inputs=text_input, outputs=output_text)
44
 
45
  demo.launch()
 
15
  else:
16
  raise gr.Error("Неверный пароль!")
17
 
18
+ def send_data(password, text):
19
  """Функция для сохранения данных на диск."""
20
+ if password == os.environ.get("password"):
21
+ global data
22
+ data = text
23
+ with open("data.txt", "w") as f:
24
+ f.write(data)
25
+ raise gr.Info("Данные успешно сохранены!")
26
+ return get_data()
27
+ else:
28
+ raise gr.Error("Неверный пароль!")
29
 
30
  css = """
31
  footer {visibility: hidden !important;}
 
43
  output_text = gr.Textbox(label="Результат:")
44
 
45
  get_button.click(get_data, inputs=password_input, outputs=output_text)
46
+ send_button.click(send_data, inputs=[password_input, text_input], outputs=output_text)
47
 
48
  demo.launch()