Skip to content

Instantly share code, notes, and snippets.

@brianjking
Created February 14, 2023 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjking/10f54420ebf842b7e876079c11d5c948 to your computer and use it in GitHub Desktop.
Save brianjking/10f54420ebf842b7e876079c11d5c948 to your computer and use it in GitHub Desktop.
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):
block = gr.Blocks()
block.launch(server_name="0.0.0.0", server_port=7860)
head = gr.Markdown.update("""<center><h1>Text to Image Demo</h1><h7>(nothing works though, it's a Password Demo)</h7></center>""")
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment