aliabd HF staff commited on
Commit
e997812
·
1 Parent(s): 9bddaba

Upload with huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +6 -6
  2. app.py +31 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Blocks Component Shortcut
3
- emoji: 😻
4
- colorFrom: red
5
- colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.3.1
 
8
  app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: blocks_component_shortcut
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.3.1
9
+
10
  app_file: app.py
11
  pinned: false
12
  ---
 
 
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ def greet(str):
5
+ return str
6
+
7
+
8
+ with gr.Blocks() as demo:
9
+ """
10
+ You can make use of str shortcuts you use in Interface within Blocks as well.
11
+
12
+ Interface shortcut example:
13
+ Interface(greet, "textarea", "textarea")
14
+
15
+ You can use
16
+ 1. gr.component()
17
+ 2. gr.templates.Template()
18
+ 3. gr.Template()
19
+ All the templates are listed in gradio/templates.py
20
+ """
21
+ with gr.Row():
22
+ text1 = gr.component("textarea")
23
+ text2 = gr.TextArea()
24
+ text3 = gr.templates.TextArea()
25
+ text1.change(greet, text1, text2)
26
+ text2.change(greet, text2, text3)
27
+ text3.change(greet, text3, text1)
28
+ button = gr.component("button")
29
+
30
+ if __name__ == "__main__":
31
+ demo.launch()