acecalisto3 commited on
Commit
75e1f41
·
verified ·
1 Parent(s): 9951e4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -15
app.py CHANGED
@@ -16,15 +16,6 @@ import datetime
16
  import feedparser
17
  from huggingface_hub import InferenceClient
18
  import validators
19
- from selenium import webdriver
20
- from selenium.webdriver.chrome.service import Service
21
- from selenium.webdriver.chrome.options import Options
22
- from selenium.webdriver.common.by import By
23
- from selenium.common.exceptions import (WebDriverException,
24
- NoSuchElementException,
25
- TimeoutException,
26
- StaleElementReferenceException)
27
- from webdriver_manager.chrome import ChromeDriverManager
28
 
29
  # Load environment variables
30
  load_dotenv()
@@ -212,13 +203,15 @@ with gr.Blocks() as demo:
212
  stop_button.click(on_stop_click, outputs=[status_text])
213
  send_button.click(chatbot_response, inputs=[message_input, chatbot_interface], outputs=[chatbot_interface, chatbot_interface])
214
 
215
- async def update_feed_content():
216
- """Generate RSS feed."""
217
- return generate_rss_feed()
 
 
 
218
 
219
- feed_timer = gr.Interval(300) # Update the feed every 300 seconds (5 minutes)
220
- feed_timer.start()
221
- feed_timer.attach(update_feed_content, output_names="output")
222
 
223
  if __name__ == "__main__":
224
  demo.launch()
 
16
  import feedparser
17
  from huggingface_hub import InferenceClient
18
  import validators
 
 
 
 
 
 
 
 
 
19
 
20
  # Load environment variables
21
  load_dotenv()
 
203
  stop_button.click(on_stop_click, outputs=[status_text])
204
  send_button.click(chatbot_response, inputs=[message_input, chatbot_interface], outputs=[chatbot_interface, chatbot_interface])
205
 
206
+ async def periodic_rss_update():
207
+ """Update the RSS feed content every 300 seconds."""
208
+ while True:
209
+ updated_feed = generate_rss_feed()
210
+ feed_content.update(value=updated_feed)
211
+ await asyncio.sleep(300) # Wait for 300 seconds before updating again
212
 
213
+ # Launch the RSS feed update task
214
+ asyncio.create_task(periodic_rss_update())
 
215
 
216
  if __name__ == "__main__":
217
  demo.launch()