Spaces:
Sleeping
Sleeping
Pooja P
commited on
Commit
Β·
29b0ceb
1
Parent(s):
998184c
added download and copuy button
Browse files
app.py
CHANGED
@@ -49,44 +49,44 @@ Use markdown formatting with ## for subheadings. Keep the tone conversational.
|
|
49 |
return f"β Failed to generate blog: {str(e)}"
|
50 |
|
51 |
# Gradio Interface
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
# Gradio Blocks version to add extra buttons
|
61 |
-
with gr.Blocks() as demo:
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
69 |
|
70 |
-
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
|
76 |
-
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
-
demo.launch(share=True)
|
|
|
49 |
return f"β Failed to generate blog: {str(e)}"
|
50 |
|
51 |
# Gradio Interface
|
52 |
+
gr.Interface(
|
53 |
+
fn=generate_blog,
|
54 |
+
inputs=gr.Textbox(label="Blog Topic"),
|
55 |
+
outputs=gr.Textbox(label="Generated Blog"),
|
56 |
+
title="π AI Blog Writer",
|
57 |
+
description="Enter a topic and get a well-written blog post.",
|
58 |
+
).launch(share=True)
|
59 |
|
60 |
# Gradio Blocks version to add extra buttons
|
61 |
+
# with gr.Blocks() as demo:
|
62 |
+
# gr.Markdown("## π AI Blog Writer\nEnter a topic and get a well-written blog post.")
|
63 |
|
64 |
+
# with gr.Row():
|
65 |
+
# topic_input = gr.Textbox(label="Blog Topic", placeholder="e.g. Clean energy")
|
66 |
|
67 |
+
# with gr.Row():
|
68 |
+
# generate_btn = gr.Button("βοΈ Generate Blog")
|
69 |
|
70 |
+
# blog_output = gr.Textbox(label="Generated Blog", lines=20)
|
71 |
|
72 |
+
# with gr.Row():
|
73 |
+
# copy_btn = gr.Button("π Copy to Clipboard")
|
74 |
+
# download_btn = gr.Button("β¬οΈ Download Blog")
|
75 |
|
76 |
+
# download_file = gr.File(label="Download", visible=False)
|
77 |
|
78 |
+
# def copy_text(text):
|
79 |
+
# # No-op: client handles clipboard via JS
|
80 |
+
# return text
|
81 |
|
82 |
+
# def download_blog(text):
|
83 |
+
# filepath = "generated_blog.txt"
|
84 |
+
# with open(filepath, "w", encoding="utf-8") as f:
|
85 |
+
# f.write(text)
|
86 |
+
# return filepath
|
87 |
|
88 |
+
# generate_btn.click(fn=generate_blog, inputs=topic_input, outputs=blog_output)
|
89 |
+
# copy_btn.click(fn=copy_text, inputs=blog_output, outputs=blog_output)
|
90 |
+
# download_btn.click(fn=download_blog, inputs=blog_output, outputs=download_file)
|
91 |
|
92 |
+
# demo.launch(share=True)
|