这样好像可以删除掉
```
from flask import Flask, request, send_file, abort,after_this_request
import ffmpeg
import os
import tempfile
import time
app = Flask(__name__)
@
app.route('/audio_appledevices/<name>.m4a', methods=['GET'])
def convert_audio(name):
ogg_path = f'./audio/{name}.ogg'
if not os.path.exists(ogg_path):
abort(404)
with tempfile.NamedTemporaryFile(delete=False, suffix='.m4a') as temp_file:
m4a_path =
temp_file.name try:
ffmpeg.input(ogg_path).output(m4a_path, codec='alac').run(overwrite_output=True)
response = send_file(m4a_path, as_attachment=True, download_name=f'{name}.m4a', mimetype='audio/mp4')
print("run m4a_path",m4a_path)
@
after_this_request def cleanup(response):
print("run cleanup")
time.sleep(1)
if os.path.exists(m4a_path):
os.remove(m4a_path)
return response
return response
except ffmpeg.Error as e:
abort(500)
if __name__ == '__main__':
app.run(host='127.0.0.1', port=3389)
```