import gradio as gr | |
user_db={"用户名":"畅心","密码":"123456"} | |
def fx(x:str): | |
return '欢迎浏览:'+x | |
demo = gr.Blocks() | |
with demo: | |
gr.Dataframe(headers=['项目','数据'],interactive=True) | |
text_input=gr.Textbox(placeholder='请输入测试字符串',label="请输入测试内容") | |
bt=gr.Button("运行") | |
bt.click(fx, inputs=text_input, outputs=gr.Textbox(label="输出")) | |
demo.launch(enable_queue=True,auth=lambda a,b:user_db.get(a)==b,auth_message="欢迎使用本web app") | |