Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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"
|
| 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.
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 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=[
|
| 69 |
-
|
| 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()
|