I am trying to create a document monitoring script with flask and watchdog
what I want to do is, if a file change in a directory it should immediately show in a web page. (if the web page is open in a browser)
initially, I tried printing the file change in the console while using below script, when I routed to the localhost:5000/monitor in the browser, the browser is loading for a long time and if the file is changed it shows in the console out. I cannot understand why the browser is stuck can someone help me to understand this
@webapp.route('/monitor', methods=['GET', 'POST'])
def monitor():
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
# path = sys.argv[1] if len(sys.argv) > 1 else '.'
path = 'I:\\Projects\\files\\.'
event_handler = LoggingEventHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
return 'monitor script running'