-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathapp.py
48 lines (38 loc) · 1.46 KB
/
app.py
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
import gradio as gr
import traceback
def hello_world_fn(username: str) -> tuple[str, str]:
try:
return f"HELLO WORLD\n{username.upper()}", "SUCCESS"
except Exception as e:
return f"opus! some exception {e}\n{traceback.format_exc()}", "FAILED"
def main() -> None:
with gr.Blocks(title="DeepLang Data test project") as demo:
with gr.Tab("hello world 0"):
raw_input = gr.Textbox(lines=1, placeholder="输入你的名字(英文)", label="")
pack_output = gr.Textbox(label="输出")
status_output = gr.Textbox(label="状态信息")
btn = gr.Button("开始转换")
btn.click(
fn=hello_world_fn,
inputs=raw_input,
outputs=[pack_output, status_output],
)
with gr.Tab("hello world 1"):
raw_input = gr.Textbox(lines=1, placeholder="输入你的名字(英文)", label="")
pack_output = gr.Textbox(label="输出")
status_output = gr.Textbox(label="状态信息")
btn = gr.Button("开始转换")
btn.click(
fn=hello_world_fn,
inputs=raw_input,
outputs=[pack_output, status_output],
)
demo.queue(default_concurrency_limit=100).launch(
inline=False,
debug=False,
server_name="127.0.0.1",
server_port=8081,
show_error=True,
)
if __name__ == "__main__":
main()