Spaces:
Running
Running
Update pages/hello.py
Browse files- pages/hello.py +32 -3
pages/hello.py
CHANGED
|
@@ -1,9 +1,38 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
with gr.Blocks() as demo:
|
| 4 |
-
gr.
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
if __name__ == "__main__":
|
| 9 |
demo.launch()
|
|
|
|
| 1 |
+
# pages/hello.py
|
| 2 |
import gradio as gr
|
| 3 |
+
from auth import check_password
|
| 4 |
|
| 5 |
with gr.Blocks() as demo:
|
| 6 |
+
with gr.Column(visible=True) as pwd_section:
|
| 7 |
+
gr.Markdown("## Enter Password to Access My Page")
|
| 8 |
+
pwd_in = gr.Textbox(label="Password", type="password")
|
| 9 |
+
pwd_fb = gr.Textbox(label="Status", interactive=False)
|
| 10 |
+
pwd_btn = gr.Button("Submit")
|
| 11 |
+
|
| 12 |
+
with gr.Column(visible=False) as content:
|
| 13 |
+
gr.Markdown("# My Custom Page")
|
| 14 |
+
gr.HTML("<h1 style='text-align:center; color: green; margin-top: 50px;'>hello world</h1>")
|
| 15 |
+
gr.Markdown("這是可分享的獨立頁面!URL:`your-space.hf.space/hello`")
|
| 16 |
+
gr.HTML("""
|
| 17 |
+
<div style="text-align: center; margin-top: 30px;">
|
| 18 |
+
<a href="/" target="_self">
|
| 19 |
+
<button style="
|
| 20 |
+
background-color: #2196F3;
|
| 21 |
+
color: white;
|
| 22 |
+
padding: 12px 30px;
|
| 23 |
+
font-size: 16px;
|
| 24 |
+
font-weight: bold;
|
| 25 |
+
border: none;
|
| 26 |
+
border-radius: 8px;
|
| 27 |
+
cursor: pointer;
|
| 28 |
+
">
|
| 29 |
+
Back to Main App
|
| 30 |
+
</button>
|
| 31 |
+
</a>
|
| 32 |
+
</div>
|
| 33 |
+
""")
|
| 34 |
+
|
| 35 |
+
pwd_btn.click(check_password, pwd_in, [pwd_section, content, pwd_fb])
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
demo.launch()
|