from os import listdir from os.path import join from flask import Flask, render_template from markupsafe import escape from subprocess import check_output app = Flask(__name__) samplefiles = listdir("samples") samples = [] for f in samplefiles: if ".wav" in f: samples.append(f.replace(".wav", "")) output = check_output(['amixer', 'sset', 'Master', 'unmute']) @app.route("/") def hello(): return render_template("index.html", samples=samples) @app.route("/play/") def door(sample): if sample in samples: play_output = check_output(['aplay', '-D', 'hw:0,0', join("samples", f"{sample}.wav")]) return f"

{escape(sample)}!

" else: return "no such sample"