How to delete wav files older than 5 minutes in Python

Solution
import time
# time.time() gives you the current time
# os.path.getmtime(path) give you the modified time for a file
for filename in list_of_files:
    if filename[-3:]!='wav':
        continue

    modified_time=os.path.getmtime(filename)
    if time.time()-modified_time > 300: #time in seconds
        os.remove(filename)
from flask import Flask, render_template, request
import inference
import os

app = Flask(__name__)
app.static_folder = 'static'

@app.route("/")
def home():
    return render_template("index.html")

@app.route("/sentez", methods = ["POST"])
def sentez():
    if request.method == "POST":
        list_of_files = os.listdir('static')
        print(list_of_files)
        for filename in list_of_files:
            if filename[-3:]!='wav':
                continue
            modified_time=os.path.getmtime(filename)
            if time.time()-modified_time > 300: #time in seconds
                os.remove(filename)
        metin = request.form["metin"]
        created_audio, file_path = inference.create_model(metin)
        return render_template("index.html", my_audio = created_audio, audio_path = file_path)
    return render_template("index.html")

if __name__ == "__main__":
    app.run();