I use Flask+Python to locate relevant files for further processing. Currently I'm only able to upload files to a specified directory with the following:
Backend:
from flask import Flask, render_template, request
from werkzeug import secure_filename
app = Flask(__name__)
@app.route('/upload')
def upload_file():
return render_template('upload.html')
@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
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)
Frontend:
<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>
But I have several problems and questions with this solution:
- I don't want actually touch (move/upload) any file, I only need the filenames of the selected files. How to discard the actual uploading and get the filenames as a list?
- Is there any way to select a directory (and not specific files) for batch processing?