How to put a progress bar for a process in Flask?

1

Hello,

When you click the 'Submit' button, the selected file (.jpg) is copied to several directories. I want to show this process to the user through a simple progress bar. Any tips?

This is part of my script to copy the selected file to other folders:

def copia_imagem():
    for root, dirs, files in os.walk(destination):
        for name in files:
            if fnmatch.fnmatch(name, 'imagem.jpg'): #Se já existir uma imagem com o mesmo nome, ela será renomeada
                os.rename(os.path.join(root, name), os.path.join(root, 'Imagem_'+date.strftime('%H%M%S__%d_%m_%Y')+'.jpg'))
        for dst in root:
            shutil.copy(os.path.join('C:/Python34/Scripts/static/img', 'imagem.jpg'), root)

My html code ...

<form method=POST enctype=multipart/form-data action="{{ url_for('upload') }}">
    <input type=file name=photo multiple>
    <button type="submit" class="btn btn-primary btn-sm">Enviar</button>
    <div class="progress" style="width: 50%; margin: 50px;">
        <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 40%">
    </div>
</form>
    
asked by anonymous 11.05.2016 / 20:03

0 answers