Commit
•
b1be69e
1
Parent(s):
93ccd1b
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Define the pre-stored text snippets
|
4 |
+
snippet1 = "This is the first predefined text snippet."
|
5 |
+
snippet2 = "This is the second predefined text snippet."
|
6 |
+
|
7 |
+
def insert_snippet1(text):
|
8 |
+
return text + snippet1
|
9 |
+
|
10 |
+
def insert_snippet2(text):
|
11 |
+
return text + snippet2
|
12 |
+
|
13 |
+
def preview_text(text):
|
14 |
+
return text
|
15 |
+
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
gr.Markdown("# Blog Writing Helper")
|
18 |
+
|
19 |
+
with gr.Row():
|
20 |
+
with gr.Column():
|
21 |
+
text_input = gr.Textbox(lines=10, placeholder="Write your blog here...", label="Text Editor")
|
22 |
+
button1 = gr.Button("Insert Snippet 1")
|
23 |
+
button2 = gr.Button("Insert Snippet 2")
|
24 |
+
with gr.Column():
|
25 |
+
markdown_preview = gr.Markdown(label="Live Preview")
|
26 |
+
|
27 |
+
button1.click(insert_snippet1, inputs=text_input, outputs=text_input)
|
28 |
+
button2.click(insert_snippet2, inputs=text_input, outputs=text_input)
|
29 |
+
text_input.change(preview_text, inputs=text_input, outputs=markdown_preview)
|
30 |
+
|
31 |
+
demo.launch()
|