@app.route("/test")
def test_func():
@after_this_request
def delete_file(response):
os.remove('test.txt')
return response
return send_file('test.txt')
I have test.txt in the same directory as my code. All I wanna do is delete the file I send, but when I access this GET method, I run into the following error:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'test.txt' 127.0.0.1 - - [12/Nov/2021 19:47:53] "GET /test HTTP/1.1" 500 -
thank you in advance