diff --git a/app.py b/app.py index 19af596..11b939b 100644 --- a/app.py +++ b/app.py @@ -24,8 +24,8 @@ def convert_to_wav(file_name: str): print(f"{extension=}") command = [ "tape2wav", - file_name, - f"${output}.wav", + os.path.join("uploads", file_name), + os.path.join("uploads", f"${output}.wav"), ] try: check_call(command) @@ -35,10 +35,13 @@ def convert_to_wav(file_name: str): def run_cassetta(cassetta: str): - command = f"aplay uploads/{cassetta}" + command = [ + "aplay", + os.path.join("uploads", cassetta), + ] try: - check_call(command.split()) + check_call(command) except CalledProcessError as exc: print(f"aplay failed: {exc.output=}\n{exc.stderr=}") @@ -72,7 +75,10 @@ def upload_file(): return "No file?" save_path = os.path.join("uploads", file.filename) - assert not os.path.exists(save_path) + if os.path.exists(save_path): + response = make_response(make_response("file already exists", 400)) + response.headers["Location"] = "/" + response.status_code = 400 try: file.save(save_path)