I'm not able to upload files through a simple form, using Flask.
I wrote below the simplified code of the html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Debug</title>
</head>
<body>
<form id="form_id" target="" action="" enctype="multipart/form-data" method = "POST">
<input type="file" name="file">
<button type="submit" name="action" value="add">Upload</button>
</form>
</body>
</html>
And the Python Flask backend:
from flask import Flask, request, render_template
app = Flask(__name__)
app.config['SECRET_KEY'] = 'JUST_FOR_TEST'
@app.route("/", methods=['GET', 'POST'])
def debugger():
args = request.args.to_dict()
if args != {}:
return str(args)
else:
return render_template('debug.html')
if __name__ == "__main__":
app.run(debug=True)
What should I fix for this form to work? Thank you all for your support.