Streamlit Adventures Part 5

Building a Real-Time File Monitor with Streamlit

A Tale of Synchronization, Queues, and Friendly Banter

On a sunny afternoon in Austin, Texas, Rick and Chris were lounging at their favorite coffee shop, laptops open, cups of coffee steaming. Their latest project, Meeting Buddy, was giving them a bit of a headache.

Rick: Sipping his coffee "You know, Chris, the file drop synchronization just isn't working as expected. The UI isn't updating when new files are added."

Chris: "Yeah, I noticed that. It's like the UI is oblivious to the new markdown files we generate during meetings."

Rick: "Exactly! We need a way to have the UI respond in real-time as files are added or removed from the directory."

Chris: Grinning "Sounds like a job for the watchdog library and a bit of Streamlit magic!"

Rick: "Agreed. Let's break it down and build a simple prototype that listens to a directory and updates the UI accordingly."

They clinked their coffee mugs together, ready to embark on another coding adventure.


The Challenge

Rick and Chris wanted their Meeting Buddy app to display meeting notes in real-time as they were being transcribed and saved as markdown files. However, the UI wasn't updating when new files were added to the directory.

Objectives


Rick and Chris decided to work on a straightforward project that monitors a file directory. Their goal was to create a simple application that listens for changes in a specified folder. When a file is added to or deleted from the directory, the application would respond with a notification.

To keep the project simple, they implemented a basic user interface that displays messages related to the file events. For instance, if a file is deleted, the UI will show "A file got deleted," and if a file is added, it will display "A file got added."