DiamondYin commited on
Commit
95ed471
·
1 Parent(s): 79820f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -1
app.py CHANGED
@@ -1,7 +1,38 @@
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
 
 
 
 
 
 
 
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
+ #import gradio as gr
2
+
3
+ #def greet(name):
4
+ # return "Hello " + name + "!!"
5
+
6
+ #iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ #iface.launch()
8
+
9
+
10
  import gradio as gr
11
 
12
+ key = ""
13
+
14
+ def get_key(k):
15
+ global key
16
+ key = k
17
+ return "Key saved successfully!"
18
+
19
  def greet(name):
20
  return "Hello " + name + "!!"
21
 
22
+ iface = gr.Interface(fn=greet, inputs=["text", gr.inputs.Textbox()], outputs="text",
23
+ inputs_layout="vertical", outputs_layout="vertical",
24
+ title="Greeting App", description="Enter a key and a name to greet")
25
+
26
+ iface.inputs[0].label = "Enter a key"
27
+ iface.inputs[1].label = "Enter a name"
28
+ iface.inputs[1].lines = 1
29
+
30
+ iface.buttons[0].label = "Save Key"
31
+ iface.buttons[0].type = "submit"
32
+ iface.buttons[0].onclick = get_key
33
+
34
+ iface.buttons[1].label = "Greet"
35
+ iface.buttons[1].type = "submit"
36
+ iface.buttons[1].onclick_args = {"name": iface.inputs[1].value}
37
+
38
  iface.launch()