Pamudu13 commited on
Commit
08e53cf
·
verified ·
1 Parent(s): 8277e33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -11,6 +11,11 @@ from web_scraper import research_topic
11
  import queue
12
  import threading
13
 
 
 
 
 
 
14
  # Create a queue for log messages
15
  log_queue = queue.Queue()
16
 
@@ -24,9 +29,13 @@ class QueueHandler(logging.Handler):
24
  logger = logging.getLogger()
25
  queue_handler = QueueHandler()
26
  queue_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
 
27
  logger.addHandler(queue_handler)
28
  logger.setLevel(logging.INFO)
29
 
 
 
 
30
  app = Flask(__name__)
31
  # Enable CORS with specific settings
32
  CORS(app, resources={
 
11
  import queue
12
  import threading
13
 
14
+ # Create a logging filter to suppress socket warnings
15
+ class SocketWarningFilter(logging.Filter):
16
+ def filter(self, record):
17
+ return not (record.levelname == 'WARNING' and 'socket.send()' in record.getMessage())
18
+
19
  # Create a queue for log messages
20
  log_queue = queue.Queue()
21
 
 
29
  logger = logging.getLogger()
30
  queue_handler = QueueHandler()
31
  queue_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
32
+ queue_handler.addFilter(SocketWarningFilter()) # Add the filter to the handler
33
  logger.addHandler(queue_handler)
34
  logger.setLevel(logging.INFO)
35
 
36
+ # Also add the filter to the root logger to catch all socket warnings
37
+ logging.getLogger().addFilter(SocketWarningFilter())
38
+
39
  app = Flask(__name__)
40
  # Enable CORS with specific settings
41
  CORS(app, resources={