Pooja P commited on
Commit
29b0ceb
Β·
1 Parent(s): 998184c

added download and copuy button

Browse files
Files changed (1) hide show
  1. app.py +30 -30
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
- # 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)
 
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)