Code of how the web application picks the file:

#Load Data
this_dir = Path(__file__).parent if '__file__' in locals() else Path.cwd()
wb_file_path = this_dir / 'vital_log_2026-03-13_21-20-51.csv'
data = pd.read_csv(wb_file_path)  

Code to the logging class that saves files to logging folder:

code to the logging class that saves files to logging folder

Example of how logs are stored in a folder:

example of how logs are stored in folder

I have a python program that creates a web application that showcases heart rate and breath rate graphs. The data that populates the graphs is taken from my mmWave RF sensor. It stores the created logs into a folder. For my web application I have hard coded the file path to one example excel just to see if it works. My question is how do I make it so that the web application populates the graph with the last file that was added to the log folder automatically?

this is the code I have now for the web application program:

this_dir = Path(__file__).parent if '__file__' in locals() else Path.cwd()

wb_file_path = this_dir / 'vital_log_2026-03-13_21-20-51.csv'

data = pd.read_csv(wb_file_path)  

this is the code in the logging class that creates the csv file:

import pandas as pd
import os
from datetime import datetime

# Create logs folder
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
LOG_FOLDER = os.path.join(BASE_DIR, "logs")
os.makedirs(LOG_FOLDER, exist_ok=True)

file_name = os.path.join(
    LOG_FOLDER,
    f"vital_log_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.xls"
)

def log_vital_frame(outputDict):

    if "vitals" not in outputDict:
        return

    vitals = outputDict["vitals"]

    timestamp = "'" + datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    df = pd.DataFrame({
        "Timestamp": [timestamp],
        "Frame": [outputDict.get("frameNum")],
        "TrackID": [vitals.get("id")],
        "RangeBin": [vitals.get("rangeBin")],
        "HeartRate_BPM": [vitals.get("heartRate")],
        "BreathRate_BPM": [vitals.get("breathRate")],
        "BreathDeviation": [vitals.get("breathDeviation")]
    })

    if not os.path.isfile(file_name):
        df.to_csv(file_name, index=False)
    else:
        df.to_csv(file_name, mode='a', header=False, index=False)