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("""

Enter Secret Password

(the password is: password)
""") 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("""

Access Denied

Reload Page to try again
""") 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("""

Enter Secret Password

""") 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)