File size: 1,955 Bytes
c156ea1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43b78d0
c156ea1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43b78d0
825bf64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gradio as gr
import os
ok = os.getenv("P") 

def checks(pass_box, cnt):
    
    if str(pass_box) != str(ok):
        if int(cnt) > 0:
            head = gr.Markdown.update("""<center><h1>Enter Secret Password</h1><h7>(the password is: password)</h7></center>""")
            pass_box = gr.Textbox.update(value=None, placeholder=f"{cnt} tries remaining")
            check = gr.update(visible=True)
            granted = gr.update(visible=False)
            cnt = int(cnt) - 1
        else:
            head = gr.Markdown.update("""<center><h1>Access Denied</h1><h7>Reload Page to try again</h7></center>""")
            pass_box = gr.update(visible=False)
            check = gr.update(visible=False)
            granted = gr.update(visible=False)
            pass
    elif str(pass_box) == str(ok):
        gr.Interface.load("spaces/eugenesiow/remove-bg").launch()
        pass_box = gr.update(visible=False)
        check = gr.update(visible=False)
        granted = gr.update(visible=True)
    else:
        pass
    return head, pass_box, check, granted, cnt
        
with gr.Blocks() as sentry:
    head = gr.Markdown("""<center><h1>Enter Secret Password</h1><h7></h7></center>""")

    with gr.Row(visible=True) as check:
        gr.Column()
        with gr.Column():
            pass_box = gr.Textbox(label="Enter Secret Password")
            pass_btn = gr.Button("Submit", visible=True)
        gr.Column()
    with gr.Row(visible=False) as granted:
        gr.Column()
        with gr.Column():
            words = gr.Markdown("""""")
            this = gr.Textbox()
            that = gr.Image()    
            btn = gr.Button()
            cnt = gr.Textbox(value=5, visible=False, interactive=False)    
        gr.Column()
    pass_btn.click(checks, [pass_box, cnt], [head, pass_box, check, granted, cnt], show_progress=False)
#sentry.launch(show_api=False, enable_queue=False)
sentry.launch(server_name="0.0.0.0", server_port=7860)