lunarflu HF Staff commited on
Commit
160ab39
·
verified ·
1 Parent(s): 46ef2db
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import os
2
  import praw
 
 
3
  from slack_sdk import WebClient
4
  from slack_sdk.errors import SlackApiError
5
 
@@ -46,7 +48,7 @@ except Exception as e:
46
  def monitor_new_posts():
47
  try:
48
  print("Attempting to access subreddit...")
49
- subreddit_name = 'huggingface'
50
  subreddit = reddit.subreddit(subreddit_name)
51
  print(f"Successfully accessed subreddit: {subreddit.display_name}")
52
  except Exception as e:
@@ -83,4 +85,16 @@ if __name__ == "__main__":
83
  print("Starting main function...")
84
  monitor_new_posts()
85
  except Exception as e:
86
- print(f"An error occurred in the main function: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import praw
3
+ from concurrent.futures import ThreadPoolExecutor
4
+ import gradio as gr
5
  from slack_sdk import WebClient
6
  from slack_sdk.errors import SlackApiError
7
 
 
48
  def monitor_new_posts():
49
  try:
50
  print("Attempting to access subreddit...")
51
+ subreddit_name = 'politics' # test
52
  subreddit = reddit.subreddit(subreddit_name)
53
  print(f"Successfully accessed subreddit: {subreddit.display_name}")
54
  except Exception as e:
 
85
  print("Starting main function...")
86
  monitor_new_posts()
87
  except Exception as e:
88
+ print(f"An error occurred in the main function: {e}")
89
+
90
+
91
+ REPORT = ""
92
+ def log(msg):
93
+ global REPORT
94
+ REPORT += "\n\n" + msg
95
+
96
+ with gr.Blocks() as demo:
97
+ gr.Markdown("Background job running to check for access requests...")
98
+ report = gr.Markdown()
99
+ report.attach_load_event(lambda: REPORT, every=1)
100
+ ThreadPoolExecutor(max_workers=1).submit(monitor_new_posts)