I need to create a utility which can store an entire folder, folders or files through Flask, at the moment I am using the following code to upload 1 file at a time
flask code:
from flask import Flask, render_template, request
from werkzeug.utils import secure_filename
app = Flask(__name__)
@app.route('/')
def upload_file():
return render_template('upload.html')
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file1():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
return 'file uploaded successfully'
if __name__ == '__main__':
app.run(debug = True)
html code:
<html>
<body>
<form action = "http://localhost:5000/uploader" method = "POST"
enctype = "multipart/form-data">
<input type = "file" name = "file" />
<input type = "submit"/>
</form>
</body>
</html>
and I receive the following dialog box:
but this only allows me to insert a single file at a time.
I require something which can allow me to upload an entire directory or multiple files together. Can it be done using Flask? If not, is there any alternative which is available in Python? Any help on the matter will really be appreciated!