I created this html:
<!DOCTYPE html>
<html lang="en" xmlns:https="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Upload Test</title>
</head>
<body>
<form action="http://localhost:8887/upload/" method="post">
<label class="btn btn-default btn-file">Browse
<input type="file" class="hidden"/>
</label>
<br>
<input class="btn btn-default" type="submit">
</form>
</body>
</html>
So I'm trying to upload data from front end to back end. On back end side I'm using this code:
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/upload/', methods=['POST', 'GET'])
def upload():
print(request.files)
return 'hey'
if __name__ == '__main__':
app.run('0.0.0.0', 8887)
The result of the line print(request.files)
is always
ImmutableMultiDict([])
I can't understand where is my mistake ?