ritwikmoitra commited on
Commit
f722cc4
·
verified ·
1 Parent(s): 7f3e417

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -33,11 +33,11 @@ def fetch_all_hindi_agri_news():
33
  def render_news(news_items, start, count=20):
34
  sliced = news_items[start:start+count]
35
  if not sliced:
36
- return " आपने सभी समाचार देख लिए हैं।"
37
  result = ""
38
  for i, item in enumerate(sliced, start + 1):
39
- result += f"**{i}. {item['title']}**<br>\n"
40
- result += f"<a href='{item['link']}' style='text-decoration: none; color: blue;'>🔗 समाचार लिंक</a><br>\n"
41
  result += f"🗓️ प्रकाशित: {item['published']}<br>\n"
42
  result += f"<hr style='margin: 10px 0;' />\n"
43
  return result
@@ -56,17 +56,15 @@ def load_more_news(news_state, current_index):
56
 
57
  # Gradio App
58
  with gr.Blocks(title="निंजा किसान कृषि समाचार") as demo:
59
- gr.Markdown("<h1 style='text-align: center;'>निंजा किसान कृषि समाचार</h1>", elem_id="title")
60
 
61
- # load_more_top = gr.Button("🔄 Load More")
62
- output_md = gr.Markdown()
63
- load_more_bottom = gr.Button("🔄 Load More")
64
 
65
  news_state = gr.State([])
66
  news_index = gr.State(0)
67
 
68
- demo.load(fn=load_initial_news, outputs=[output_md, news_state, news_index])
69
- # load_more_top.click(fn=load_more_news, inputs=[news_state, news_index], outputs=[output_md, news_index])
70
- load_more_bottom.click(fn=load_more_news, inputs=[news_state, news_index], outputs=[output_md, news_index])
71
 
72
  demo.launch()
 
33
  def render_news(news_items, start, count=20):
34
  sliced = news_items[start:start+count]
35
  if not sliced:
36
+ return "<p>✅ आपने सभी समाचार देख लिए हैं।</p>"
37
  result = ""
38
  for i, item in enumerate(sliced, start + 1):
39
+ result += f"<strong>{i}. {item['title']}</strong><br>\n"
40
+ result += f"<a href='{item['link']}' target='_self' style='text-decoration: none; color: blue;'>🔗 समाचार लिंक</a><br>\n"
41
  result += f"🗓️ प्रकाशित: {item['published']}<br>\n"
42
  result += f"<hr style='margin: 10px 0;' />\n"
43
  return result
 
56
 
57
  # Gradio App
58
  with gr.Blocks(title="निंजा किसान कृषि समाचार") as demo:
59
+ gr.HTML("<h1 style='text-align: center;'>निंजा किसान कृषि समाचार</h1>", elem_id="title")
60
 
61
+ output_html = gr.HTML()
62
+ load_more_bottom = gr.Button("🔄 और समाचार देखें")
 
63
 
64
  news_state = gr.State([])
65
  news_index = gr.State(0)
66
 
67
+ demo.load(fn=load_initial_news, outputs=[output_html, news_state, news_index])
68
+ load_more_bottom.click(fn=load_more_news, inputs=[news_state, news_index], outputs=[output_html, news_index])
 
69
 
70
  demo.launch()