I have a program that takes audio files and processes it.
@app.route('/', methods=['GET', 'POST'])
def hello_world():
if request.method == 'GET':
return render_template('upload.html')
else:
file = request.files['file']
path = os.getcwd() + '\\tempFilesAudio\\'
if not os.path.exists(os.getcwd() + '\\' + 'tempFilesAudio'):
os.mkdir(os.getcwd() + '\\' + 'tempFilesAudio')
if not os.path.exists(os.getcwd() + '\\' + 'tempFilesTransciption'):
os.mkdir(os.getcwd() + '\\' + 'tempFilesTransciption')
file.save(path + secure_filename(file.filename))
file_path = path + file.filename
conv_path = convert(file_path)
print('converted:{}'.format(conv_path))
#this is a thread
Recogniser(conv_path)
print('Deleting MP3')
os.remove(file_path)
print('Deleting WAV')
os.remove(conv_path)
return render_template('upload.html')
I want my UI to be re-rendered after the files have been submitted to the thread for processing in the background. But it still keeps waiting.
Below is the code for my thread:
class Recogniser:
def __init__(self, file):
self.executor = ThreadPoolExecutor(5)
self.file = file
thread = threading.Thread(target=self.run(), daemon=True, args=file)
thread.start()
def run(self):
#something